diff --git a/.github/workflows/accept-baselines-fix-lints.yaml b/.github/workflows/accept-baselines-fix-lints.yaml index 0038167e35012..2662646cc05fe 100644 --- a/.github/workflows/accept-baselines-fix-lints.yaml +++ b/.github/workflows/accept-baselines-fix-lints.yaml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use node version 12 - uses: actions/setup-node@v1 + - name: Use node version 14 + uses: actions/setup-node@v3 with: - node-version: 12 + node-version: 14 registry-url: https://registry.npmjs.org/ - name: Configure Git, Run Tests, Update Baselines, Apply Fixes diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aefe86e2ef848..b95b0481ed251 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,14 +16,14 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [14.x, 16.x, 18.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 5 - name: Use node version ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Remove existing TypeScript diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8cb8045ef425e..e9bc38cbcaeb8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,6 +11,7 @@ jobs: # CodeQL runs on ubuntu-latest and windows-latest runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' steps: - name: Checkout repository diff --git a/.github/workflows/ensure-related-repos-run-crons.yml b/.github/workflows/ensure-related-repos-run-crons.yml index f6faff6b67f77..a26fb5b799220 100644 --- a/.github/workflows/ensure-related-repos-run-crons.yml +++ b/.github/workflows/ensure-related-repos-run-crons.yml @@ -14,6 +14,7 @@ on: jobs: build: runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' steps: - name: Configure git diff --git a/.github/workflows/new-release-branch.yaml b/.github/workflows/new-release-branch.yaml index 6c07e96bbbbc9..90b8bbdf5efdb 100644 --- a/.github/workflows/new-release-branch.yaml +++ b/.github/workflows/new-release-branch.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Use node version 12.x - uses: actions/setup-node@v1 + - name: Use node version 14.x + uses: actions/setup-node@v3 with: - node-version: 12.x + node-version: 14.x - uses: actions/checkout@v2 with: fetch-depth: 5 diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index abe704bb564d8..d255a324f7947 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -11,13 +11,14 @@ on: jobs: build: runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' steps: - uses: actions/checkout@v2 - - name: Use node version 12 - uses: actions/setup-node@v1 + - name: Use node version 14 + uses: actions/setup-node@v3 with: - node-version: 12 + node-version: 14 registry-url: https://registry.npmjs.org/ - name: Setup and publish nightly run: | diff --git a/.github/workflows/release-branch-artifact.yaml b/.github/workflows/release-branch-artifact.yaml index 363d03fc2f69b..17bb3be4680d6 100644 --- a/.github/workflows/release-branch-artifact.yaml +++ b/.github/workflows/release-branch-artifact.yaml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use node version 12 - uses: actions/setup-node@v1 + - name: Use node version 14 + uses: actions/setup-node@v3 with: - node-version: 12 + node-version: 14 - name: Remove existing TypeScript run: | npm uninstall typescript --no-save diff --git a/.github/workflows/rich-navigation.yml b/.github/workflows/rich-navigation.yml index 4097f2893c3a2..82ba9bf54f1df 100644 --- a/.github/workflows/rich-navigation.yml +++ b/.github/workflows/rich-navigation.yml @@ -19,7 +19,7 @@ jobs: with: fetch-depth: 5 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: 14 diff --git a/.github/workflows/set-version.yaml b/.github/workflows/set-version.yaml index d5bd8faa83438..5b1338daff2aa 100644 --- a/.github/workflows/set-version.yaml +++ b/.github/workflows/set-version.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Use node version 12.x - uses: actions/setup-node@v1 + - name: Use node version 14.x + uses: actions/setup-node@v3 with: - node-version: 12.x + node-version: 14.x - uses: actions/checkout@v2 with: ref: ${{ github.event.client_payload.branch_name }} diff --git a/.github/workflows/sync-branch.yaml b/.github/workflows/sync-branch.yaml index e3f67be09fed5..fae67017c617b 100644 --- a/.github/workflows/sync-branch.yaml +++ b/.github/workflows/sync-branch.yaml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Use node version 12.x - uses: actions/setup-node@v1 + - name: Use node version 14.x + uses: actions/setup-node@v3 with: - node-version: 12.x + node-version: 14.x - uses: actions/checkout@v2 with: ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }} diff --git a/.github/workflows/twoslash-repros.yaml b/.github/workflows/twoslash-repros.yaml index f4888f5334163..36a97b49ac5ce 100644 --- a/.github/workflows/twoslash-repros.yaml +++ b/.github/workflows/twoslash-repros.yaml @@ -8,16 +8,38 @@ on: - cron: '0 8 * * *' repository_dispatch: types: run-twoslash-repros + issues: + types: + - labeled + workflow_dispatch: + inputs: + bisect_issue: + description: Triggers a bisect request on the given issue number instead of updating repros on all issues + required: false + type: string jobs: - build: + run: + if: ${{ github.repository == 'microsoft/TypeScript' && !github.event.label && !github.event.inputs.bisect_issue }} runs-on: ubuntu-latest steps: - name: Use node - uses: actions/setup-node@v1 - - run: | - npm init -y - npm install --save typescript@next + uses: actions/setup-node@v3 - uses: microsoft/TypeScript-Twoslash-Repro-Action@master with: github-token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + + bisect: + if: ${{ github.event.label.name == 'Bisect Repro' || github.event.inputs.bisect_issue }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - uses: microsoft/TypeScript-Twoslash-Repro-Action@master + with: + github-token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + bisect: ${{ github.event.issue.number || github.event.inputs.bisect_issue }} diff --git a/.github/workflows/update-lkg.yml b/.github/workflows/update-lkg.yml index cf81cc97db9fb..cac9c6c4c0665 100644 --- a/.github/workflows/update-lkg.yml +++ b/.github/workflows/update-lkg.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use node version 12 - uses: actions/setup-node@v1 + - name: Use node version 14 + uses: actions/setup-node@v3 with: - node-version: 12 + node-version: 14 registry-url: https://registry.npmjs.org/ - name: Configure Git and Update LKG diff --git a/.github/workflows/update-package-lock.yaml b/.github/workflows/update-package-lock.yaml index 0e4d1509333e3..1c54603f9ba1c 100644 --- a/.github/workflows/update-package-lock.yaml +++ b/.github/workflows/update-package-lock.yaml @@ -10,12 +10,13 @@ on: jobs: build: runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v3 with: - node-version: 12 + node-version: 14 registry-url: https://registry.npmjs.org/ - name: Configure git and update package-lock.json diff --git a/AUTHORS.md b/AUTHORS.md index b58f1a31efd33..e02b495d24240 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -169,6 +169,7 @@ TypeScript is authored by: - Gabriel Isenberg - Gabriela Araujo Britto - Gabriela Britto + - Gao Sheng - gb714us - Gilad Peleg - Godfrey Chan diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index 38f8a9b903852..a61a6f5dc4b3a 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Přidat void k objektu Promise vyřešenému bez hodnoty", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Přidat void ke všem objektům Promise vyřešeným bez hodnoty", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Přidání souboru tsconfig.json vám pomůže uspořádat projekty, které obsahují jak soubory TypeScript, tak soubory JavaScript. Další informace najdete na adrese https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Všechny deklarace {0} musí mít identická omezení.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Všechny deklarace {0} musí mít stejné modifikátory.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Všechny deklarace {0} musí mít stejné parametry typu.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Všechny deklarace abstraktní metody musí jít po sobě.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Duplicitní signatura indexu pro typ {0}.", "Duplicate_label_0_1114": "Duplicitní popisek {0}", "Duplicate_property_0_2718": "Duplicitní vlastnost {0}.", - "Dynamic_import_cannot_have_type_arguments_1326": "Dynamický import nemůže mít argumenty typu.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Specifikátor dynamického importu musí být typu string, ale tady má typ {0}.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Dynamické importy se podporují jen v případě, že příznak --module je nastavený na es2020, es2022, esnext, commonjs, amd, system, umd, node12 nebo nodenext.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Dynamické importy můžou jako argumenty přijímat jenom specifikátor modulu a volitelný kontrolní výraz.", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "Očekával se tento počet argumentů: {0}, ale byl přijat tento počet: {1}. Nezapomněli jste zahrnout void do argumentu typu pro objekt Promise?", "Expected_0_type_arguments_but_got_1_2558": "Očekávaly se argumenty typu {0}, ale předaly se argumenty typu {1}.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Očekávané argumenty typu {0}; zadejte je se značkou @extends.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "Očekával se 1 argument, ale bylo jich 0. New Promise() potřebuje pomocný parametr JSDoc k vytvoření resolve, který se dá volat bez argumentů.", "Expected_at_least_0_arguments_but_got_1_2555": "Očekával se aspoň tento počet argumentů: {0}. Počet předaných argumentů: {1}", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Očekávala se odpovídající ukončující značka JSX pro {0}.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Pro fragment JSX se očekávala odpovídající uzavírací značka.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Tato syntaxe vyžaduje importovanou pomocnou rutinu s názvem {1}, která v {0} neexistuje. Zvažte možnost upgradovat verzi {0}.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Tato syntaxe vyžaduje importovanou pomocnou rutinu s názvem {1} a parametry {2}, která není kompatibilní s tou v {0}. Zvažte upgrade verze {0}.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Tento parametr typu pravděpodobně potřebuje omezení „extends object“.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Toto použití importu není platné. Volání import() se dají zapsat, ale musí mít závorky a nemůžou mít typové argumenty.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Výrazy await nejvyšší úrovně se povolují jen v případě, že možnost module je nastavená na es2022, esnext, system nebo nodenext a možnost target je nastavená na es2017 nebo vyšší.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Deklarace nejvyšší úrovně v souborech .d.ts musí začínat modifikátorem declare, nebo export.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Smyčky for await nejvyšší úrovně se povolují jen v případě, že možnost module je nastavená na es2022, esnext, system nebo nodenext a možnost target je nastavená na es2017 nebo vyšší.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Typ {0} nepředstavuje platný návratový typ asynchronní funkce v ES5/ES3, protože neodkazuje na hodnotu konstruktoru kompatibilní s příslibem.", "Type_0_is_not_an_array_type_2461": "Typ {0} není typ pole.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "Typ {0} není typem pole nebo řetězce.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "Typ {0} není typem pole ani typem řetězce. Pokud chcete povolit iteraci iterátorů, použijte možnost kompilátoru --downlevelIteration.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "Typ {0} není typem pole nebo řetězce, nebo nemá metodu [Symbol.iterator](), která vrací iterátor.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "Typ {0} není typem pole, nebo nemá metodu [Symbol.iterator](), která vrací iterátor.", "Type_0_is_not_assignable_to_type_1_2322": "Typ {0} nejde přiřadit typu {1}.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "Seznam deklarací proměnných nemůže být prázdný.", "Variable_declaration_not_allowed_at_this_location_1440": "Deklarace proměnné není v tomto umístění povolená.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "Element variadic na pozici {0} ve zdroji neodpovídá elementu na pozici {1} v cíli.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Poznámky Variance se podporují pouze u aliasů typů pro typy objektů, funkcí, konstruktorů a mapování.", "Version_0_6029": "Verze {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Další informace o tomto souboru si můžete přečíst na https://aka.ms/tsconfig", "WATCH_OPTIONS_6918": "MOŽNOSTI SLEDOVÁNÍ", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index c14a9fb82168d..0361c0869f9d7 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "\"Void\" zu ohne Wert aufgelöstem Promise hinzufügen", "Add_void_to_all_Promises_resolved_without_a_value_95144": "\"Void\" allen ohne Wert aufgelösten Promises hinzufügen", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Das Hinzufügen einer \"tsconfig.json\"-Datei erleichtert die Organisation von Projekten, die sowohl TypeScript- als auch JavaScript-Dateien enthalten. Weitere Informationen finden Sie unter https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Alle Deklarationen von \"{0}\" müssen identische Modifizierer aufweisen.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Alle Deklarationen von \"{0}\" müssen identische Modifizierer aufweisen.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Alle Deklarationen von \"{0}\" müssen identische Typparameter aufweisen.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Alle Deklarationen einer abstrakten Methode müssen aufeinanderfolgend sein.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Doppelte Indexsignatur für Typ \"{0}\".", "Duplicate_label_0_1114": "Doppelte Bezeichnung \"{0}\".", "Duplicate_property_0_2718": "Doppelte Eigenschaft: {0}", - "Dynamic_import_cannot_have_type_arguments_1326": "Der dynamische Import kann keine Typargumente aufweisen.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Der Spezifizierer des dynamischen Imports muss den Typ \"string\" aufweisen, hier ist er jedoch vom Typ \"{0}\".", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Dynamische Importe werden nur unterstützt, wenn das \"--module\"-Kennzeichen auf \"es2020\", \"es2022\", \"esnext\", \"commonjs\", \"amd\", \"system\", \"umd\", \"node12\" oder \"nodenext\" festgelegt ist.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Dynamische Importe können nur einen Modulspezifizierer und eine optionale Assertion als Argumente akzeptieren.", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "Es wurden {0} Argumente erwartet, aber {1} erhalten. Sollte \"void\" in Ihr Typargument in \"Promise\" eingeschlossen werden?", "Expected_0_type_arguments_but_got_1_2558": "{0} Typenargumente wurden erwartet, empfangen wurden aber {1}.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "{0} Typargumente erwartet; geben Sie diese mit einem @extends-Tag an.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "1 Argument erwartet, aber 0 erhalten. „new Promise()“ benötigt einen JSDoc-Hinweis, um einen „resolve“ zu erzeugen, der ohne Argumente aufgerufen werden kann.", "Expected_at_least_0_arguments_but_got_1_2555": "Mindestens {0} Argumente wurden erwartet, empfangen wurden aber {1}.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Das entsprechende schließende JSX-Tag wurde für \"{0}\" erwartet.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Für das JSX-Fragment wurde das entsprechende schließende Tag erwartet.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Diese Syntax erfordert ein importiertes Hilfsprogramm namens \"{1}\", das in \"{0}\" nicht vorhanden ist. Erwägen Sie ein Upgrade Ihrer Version von \"{0}\".", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Diese Syntax erfordert ein importiertes Hilfsprogramm mit dem Namen \"{1}\" mit {2} Parametern, die nicht mit der in \"{0}\" kompatibel ist. Erwägen Sie ein Upgrade Ihrer Version von \"{0}\".", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Dieser Typparameter benötigt wahrscheinlich eine „extends object“-Einschränkung.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Diese Verwendung von „import“ ist ungültig. „import()“-Aufrufe können geschrieben werden, müssen jedoch Klammern aufweisen und dürfen keine Typargumente aufweisen.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "„Await“-Ausdrücke der obersten Ebene sind nur zulässig, wenn die Option \"module\" auf \"es2022\", \"esnext\", \"system\" oder \"nodenext\" festgelegt ist und die Option \"target\" auf \"es2017\" oder höher festgelegt ist.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Deklarationen der obersten Ebene in .d.ts-Dateien müssen entweder mit einem declare- oder einem export-Modifizierer beginnen.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "„For Await“-Schleifen der obersten Ebene sind nur zulässig, wenn die „module“-Option auf \"es2022\", \"esnext\", \"system\" oder \"nodenext\" festgelegt ist und die Option \"target\" auf \"es2017\" oder höher festgelegt ist.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Der Typ \"{0}\" ist in ES5/ES3 kein gültiger Rückgabetyp einer asynchronen Funktion, weil er nicht auf einen Promise-kompatiblen Konstruktorwert verweist.", "Type_0_is_not_an_array_type_2461": "Der Typ \"{0}\" ist kein Arraytyp.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "Der Typ \"{0}\" ist kein Array- oder Zeichenfolgentyp.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "Der Typ \"{0}\" ist kein Arraytyp oder Zeichenfolgentyp. Verwenden Sie die Compileroption \"--downlevelIteration\", um das Durchlaufen von Iteratoren zuzulassen.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "Typ \"{0}\" ist kein Array-Typ oder Zeichenfolgentyp oder weist keine \"[Symbol.iterator]()\"-Methode auf, die einen Iterator zurückgibt.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "Typ \"{0}\" ist kein Array-Typ oder weist keine \"[Symbol.iterator]()\"-Methode auf, die einen Iterator zurückgibt.", "Type_0_is_not_assignable_to_type_1_2322": "Der Typ \"{0}\" kann dem Typ \"{1}\" nicht zugewiesen werden.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "Die Variablendeklarationsliste darf nicht leer sein.", "Variable_declaration_not_allowed_at_this_location_1440": "Variablendeklaration ist an dieser Stelle nicht zulässig.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "Das variadic-Element an Position {0} in der Quelle stimmt nicht mit dem Element an Position {1} im Ziel überein.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Abweichungsanmerkungen werden nur in Typaliasnamen für Objekt-, Funktions-, Konstruktor- und zugeordnete Typen unterstützt.", "Version_0_6029": "Version {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Besuchen Sie https://aka.ms/tsconfig, um mehr über diese Datei zu erfahren.", "WATCH_OPTIONS_6918": "ÜBERWACHUNGSOPTIONEN", diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index 36c2328f3288f..7b7e955f27549 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Agregar \"void\" a la instancia de Promise resuelta sin un valor", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Agregar \"void\" a todas las instancias de Promise resueltas sin un valor", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Agregar un archivo tsconfig.json ayuda a organizar los proyectos que contienen archivos TypeScript y JavaScript. Más información en https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Todas las declaraciones de \"{0}\" deben tener delimitaciones idénticas.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Todas las declaraciones de '{0}' deben tener modificadores idénticos.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Todas las declaraciones de '{0}' deben tener parámetros de tipo idénticos.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Todas las declaraciones de un método abstracto deben ser consecutivas.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Signatura de índice duplicada para el tipo \"{0}\".", "Duplicate_label_0_1114": "Etiqueta \"{0}\" duplicada.", "Duplicate_property_0_2718": "Propiedad \"{0}\" duplicada.", - "Dynamic_import_cannot_have_type_arguments_1326": "La importación dinámica no puede tener argumentos de tipo.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "El especificador de la importación dinámica debe ser de tipo \"string\", pero aquí tiene el tipo \"{0}\".", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Las importaciones dinámicas solo se admiten cuando la marca \"--módulo\" está establecida en \"es2020\", \"es2022\", \"esnext\", \"commonjs\", \"amd\", \"system\", \"umd\", \"node12\" o \"nodenext\".", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Las importaciones dinámicas solo pueden aceptar un especificador de módulo y una aserción opcional como argumentos", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "Se esperaban {0} argumentos, pero se obtuvo un total de {1}. ¿Olvidó incluir \"void\" en el argumento de tipo para \"Promise\"?", "Expected_0_type_arguments_but_got_1_2558": "Se esperaban {0} argumentos de tipo, pero se obtuvieron {1}.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Se esperaban argumentos de tipo {0}; proporciónelos con una etiqueta \"@extends\".", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "Se esperaba 1 argumento, pero se obtuvo 0. \"new Promise()\" necesita una pista de JSDoc para producir un \"resolve\" que pueda llamarse sin argumentos.", "Expected_at_least_0_arguments_but_got_1_2555": "Se esperaban al menos {0} argumentos, pero se obtuvieron {1}.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Se esperaba la etiqueta de cierre JSX correspondiente de '{0}'.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Se esperaba la etiqueta de cierre correspondiente para el fragmento de JSX.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Esta sintaxis requiere una aplicación auxiliar importada denominada \"{1}\", que no existe en \"{0}\". Considere la posibilidad de actualizar la versión de \"{0}\".", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Esta sintaxis requiere un asistente importado denominado \"{1}\" con parámetros de {2}, que no es compatible con el de \"{0}\". Pruebe a actualizar la versión de \"{0}\".", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Puede que este parámetro de tipo necesite una restricción “extends object”.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Este uso de \"import\" no es válido. Se pueden escribir llamadas \"import()\", pero deben tener paréntesis y no pueden tener argumentos de tipo.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Las expresiones \"await\" de nivel superior solo se permiten cuando la opción \"módulo\" está establecida en \"es2022\", \"esnext\", \"system\" o \"nodenext\", y la opción \"destino\" está establecida en \"es2017\" o superior.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Las declaraciones de nivel superior de los archivos .d.ts deben comenzar con un modificador \"declare\" o \"export\".", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Los bucles \"for await\" de nivel superior solo se permiten cuando la opción \"módulo\" está establecida en \"es2022\", \"esnext\", \"system\" o \"nodenext\", y la opción \"destino\" está establecida en \"es2017\" o superior.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "El tipo '{0}' no es un tipo de valor devuelto válido para una función asincrónica en ES5/ES3, porque no hace referencia a un valor de constructor compatible con promesas.", "Type_0_is_not_an_array_type_2461": "'{0}' no es un tipo de matriz.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "'{0}' no es un tipo de matriz o un tipo de cadena.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "\"{0}\" no es un tipo de matriz o de cadena. Use la opción del compilador \"--downlevelIteration\" para permitir la iteración de los iteradores.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "El tipo \"{0}\" no es un tipo de matriz o un tipo de cadena o no tiene un método \"[Symbol.iterator]()\" que devuelve un iterador.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "El tipo \"{0}\" no es un tipo de matriz o no tiene un método \"[Symbol.iterator]()\" que devuelve un iterador.", "Type_0_is_not_assignable_to_type_1_2322": "El tipo '{0}' no se puede asignar al tipo '{1}'.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "La lista de declaraciones de variable no puede estar vacía.", "Variable_declaration_not_allowed_at_this_location_1440": "No se permite una declaración de variable en esta ubicación.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "El elemento variádico en la posición {0} del origen no coincide con el elemento en la posición {1} del destino.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Las anotaciones de varianza solo se admiten en alias de tipo para los tipos objeto, función, constructor y asignado.", "Version_0_6029": "Versión {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Visite https://aka.ms/tsconfig para obtener más información acerca de este archivo", "WATCH_OPTIONS_6918": "OPCIONES DE INSPECCIÓN", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index f9235173f8a28..f17d597e484f9 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Ajouter 'void' à un Promise résolu sans valeur", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Ajouter 'void' à toutes les promesses résolues sans valeur", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "L'ajout d'un fichier tsconfig.json permet d'organiser les projets qui contiennent des fichiers TypeScript et JavaScript. En savoir plus sur https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Toutes les déclarations de « {0} » doivent avoir des contraintes identiques.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Toutes les déclarations de '{0}' doivent avoir des modificateurs identiques.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Toutes les déclarations de '{0}' doivent avoir des paramètres de type identiques.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Toutes les déclarations d'une méthode abstraite doivent être consécutives.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Doublon de signature d’index pour le type « {0} ».", "Duplicate_label_0_1114": "Étiquette '{0}' en double.", "Duplicate_property_0_2718": "Propriété dupliquée '{0}'.", - "Dynamic_import_cannot_have_type_arguments_1326": "L'importation dynamique ne peut pas avoir d'arguments de type.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Le spécificateur de l'importation dynamique doit être de type 'string', mais ici il est de type '{0}'.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Les importations dynamiques sont prises en charge uniquement lorsque l’indicateur « --module » est défini sur « es2020 », « es2022 », « esnext », « commonjs », « amd », « system », « umd », « node12 » ou « nodenext ».", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Les importations dynamiques peuvent accepter uniquement un spécificateur de module et une assertion facultative en tant qu’arguments.", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "{0} arguments attendus, mais {1} reçus. Avez-vous oublié d'inclure 'void' dans votre argument de type pour 'Promise' ?", "Expected_0_type_arguments_but_got_1_2558": "{0} arguments de type attendus, mais {1} reçus.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Arguments de type {0} attendus ; indiquez-les avec la balise '@extends'.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "1 argument attendu, mais 0 obtenu. 'new Promise()' a besoin d’un indicateur JSDoc pour produire un 'resolve' qui peut être appelé sans arguments.", "Expected_at_least_0_arguments_but_got_1_2555": "Au moins {0} arguments attendus, mais {1} reçus.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Balise de fermeture JSX correspondante attendue pour '{0}'.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Balise de fermeture correspondante attendue pour le fragment JSX.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Cette syntaxe nécessite une assistance importée nommée '{1}' mais qui n'existe pas dans '{0}'. Effectuez une mise à niveau de votre version de '{0}'.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Cette syntaxe nécessite un composant d'assistance importé nommé '{1}' avec {2} paramètres, ce qui n'est pas compatible avec celui qui se trouve dans '{0}'. Effectuez une mise à niveau de votre version de '{0}'.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Ce paramètre de type nécessite probablement une contrainte 'extends object'.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Cette utilisation de « import » n’est pas valide. Les appels « import() » peuvent être écrits, mais ils doivent avoir des parenthèses et ne peuvent pas avoir d’arguments de type.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Les expressions « await » de niveau supérieur sont autorisées uniquement lorsque l’option « module » a la valeur « es2022 », « esnext », « system » ou « nodenext », et que l’option « target » a la valeur « es2017 » ou une valeur supérieure.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Les déclarations de niveau supérieur dans les fichiers .d.ts doivent commencer par un modificateur 'declare' ou 'export'.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Les boucles « for await » de niveau supérieur sont autorisées uniquement lorsque l’option « module » a la valeur « es2022 », « esnext », « system » ou « nodenext », et que l’option « target » est définie sur « es2017 » ou une version ultérieure.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Le type '{0}' n'est pas un type de retour de fonction async valide en ES5/ES3, car il ne référence pas une valeur de constructeur compatible avec une promesse.", "Type_0_is_not_an_array_type_2461": "Le type '{0}' n'est pas un type de tableau.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "Le type '{0}' n'est pas un type de tableau ou un type de chaîne.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "Le type '{0}' n’est pas un type de tableau ou un type string. Utilisez l'option du compilateur '--downlevelIteration' pour autoriser l'itération des itérateurs.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "Le type '{0}' n'est pas un type tableau ou un type chaîne, ou n'a pas de méthode '[Symbol.iterator]()' qui retourne un itérateur.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "Le type '{0}' n'est pas un type tableau ou n'a pas de méthode '[Symbol.iterator]()' qui retourne un itérateur.", "Type_0_is_not_assignable_to_type_1_2322": "Impossible d'assigner le type '{0}' au type '{1}'.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "La liste des déclarations de variable ne peut pas être vide.", "Variable_declaration_not_allowed_at_this_location_1440": "Déclaration de variable non autorisée à cet emplacement.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "L'élément variadique situé à la position {0} dans la source ne correspond pas à l'élément situé à la position {1} dans la cible.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Les annotations de variance sont uniquement prises en charge dans les alias de type pour les types objet, fonction, constructeur et mappé.", "Version_0_6029": "Version {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Visitez https://aka.ms/tsconfig pour en savoir plus sur ce fichier", "WATCH_OPTIONS_6918": "OPTIONS D’OBSERVATION", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index f1fbda551ac7c..76e2f4a81bbf4 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Aggiungere 'void' all'elemento Promise risolto senza un valore", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Aggiungere 'void' a tutti gli elementi Promise risolti senza un valore", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Aggiungere un file tsconfig.json per organizzare più facilmente progetti che contengono sia file TypeScript che JavaScript. Per altre informazioni, vedere https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Tutte le dichiarazioni di '{0}' devono avere vincoli identici.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Tutte le dichiarazioni di '{0}' devono contenere modificatori identici.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Tutte le dichiarazioni di '{0}' devono contenere parametri di tipo identici.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Tutte le dichiarazioni di un metodo astratto devono essere consecutive.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Firma dell'indice duplicata per il tipo '{0}'.", "Duplicate_label_0_1114": "Etichetta '{0}' duplicata.", "Duplicate_property_0_2718": "La proprietà '{0}' è duplicata.", - "Dynamic_import_cannot_have_type_arguments_1326": "Nell'importazione dinamica non possono essere presenti argomenti tipo.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "L'identificatore dell'importazione dinamica deve essere di tipo 'string', ma il tipo specificato qui è '{0}'.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Le importazioni dinamiche sono supportate solo quando il flag '--module' è impostato su 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12' o 'nodenext'.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Le importazioni dinamiche possono accettare come argomenti solo un identificatore di modulo e un'asserzione facoltativa", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "Sono previsti {0} argomenti, ma ne sono stati ottenuti {1}. Si è dimenticato di includere 'void' nell'argomento di tipo per 'Promise'?", "Expected_0_type_arguments_but_got_1_2558": "Sono previsti {0} argomenti tipo, ma ne sono stati ottenuti {1}.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Sono previsti {0} argomenti tipo. Per specificarli, usare un tag '@extends'.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "Previsto 1 argomento, ma ottenuto 0. 'new Promise()' richiede un hint JSDoc per produrre un elemento 'resolve' che possa essere chiamato senza argomenti.", "Expected_at_least_0_arguments_but_got_1_2555": "Sono previsti almeno {0} argomenti, ma ne sono stati ottenuti {1}.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "È previsto il tag di chiusura JSX corrispondente per '{0}'.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "È previsto il tag di chiusura corrispondente per il frammento JSX.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Con questa sintassi è richiesto un helper importato denominato '{1}', che non esiste in '{0}'. Provare ad aggiornare la versione di '{0}'.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Con questa sintassi è richiesto un helper importato denominato '{1}' con {2} parametri, che non è compatibile con quello presente in '{0}'. Provare ad aggiornare la versione di '{0}'.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Questo parametro di tipo richiede probabilmente un vincolo 'extends object'.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Questo uso di 'import' non è valido. le chiamate 'import()' possono essere scritte, ma devono avere parentesi e non possono avere argomenti di tipo.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Le espressioni 'await' di primo livello sono consentite solo quando l'opzione 'module' è impostata su 'es2022', 'esnext', 'system' o 'nodenext' e l'opzione 'target' è impostata su 'es2017' o versione successiva.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Le dichiarazioni di primo livello nei file con estensione d.ts devono iniziare con un modificatore 'declare' o 'export'.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "I cicli 'for await' di primo livello sono consentiti solo quando l'opzione 'module' è impostata su 'es2022', 'esnext', 'system' o 'nodenext' e l'opzione 'target' è impostata su 'es2017' o versione successiva.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Il tipo '{0}' non è un tipo restituito di funzione asincrona valido in ES5/ES3 perché non fa riferimento a un valore di costruttore compatibile con Promise.", "Type_0_is_not_an_array_type_2461": "Il tipo '{0}' non è un tipo matrice.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "Il tipo '{0}' non è un tipo matrice o stringa.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "Il tipo '{0}' non è un tipo matrice o stringa. Usare l'opzione del compilatore '--downlevelIteration' per consentire l'iterazione degli iteratori.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "Il tipo '{0}' non è un tipo matrice o stringa oppure non contiene un metodo '[Symbol.iterator]()' che restituisce un iteratore.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "Il tipo '{0}' non è un tipo matrice oppure non contiene un metodo '[Symbol.iterator]()' che restituisce un iteratore.", "Type_0_is_not_assignable_to_type_1_2322": "Il tipo '{0}' non è assegnabile al tipo '{1}'.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "L'elenco delle dichiarazioni di variabile non può essere vuoto.", "Variable_declaration_not_allowed_at_this_location_1440": "Dichiarazione di variabile non consentita in questa posizione.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "L'elemento variadic alla posizione {0} nell'origine non corrisponde all'elemento alla posizione {1} nella destinazione.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Le annotazioni di varianza sono supportate solo negli alias di tipo per oggetti, funzioni, costruttori e tipi mappati.", "Version_0_6029": "Versione {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Per altre informazioni su questo file, visitare https://aka.ms/tsconfig", "WATCH_OPTIONS_6918": "OPZIONI DELL'ESPRESSIONE DI CONTROLLO", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 04829a1f8bbf0..35ad3038e0e39 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "値なしで解決された Promise に 'void' を追加します", "Add_void_to_all_Promises_resolved_without_a_value_95144": "値なしで解決されたすべての Promise に 'void' を追加します", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "tsconfig.json ファイルを追加すると、TypeScript ファイルと JavaScript ファイルの両方を含むプロジェクトを整理できます。詳細については、https://aka.ms/tsconfig をご覧ください。", + "All_declarations_of_0_must_have_identical_constraints_2838": "'{0}' のすべての宣言には、同一の制約が必要です。", "All_declarations_of_0_must_have_identical_modifiers_2687": "'{0}' のすべての宣言には、同一の修飾子が必要です。", "All_declarations_of_0_must_have_identical_type_parameters_2428": "'{0}' のすべての宣言には、同一の型パラメーターがある必要があります。", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象メソッドの宣言はすべて連続している必要があります。", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "型 '{0}' のインデックス シグネチャが重複しています。", "Duplicate_label_0_1114": "ラベル '{0}' が重複しています。", "Duplicate_property_0_2718": "プロパティ '{0}' が重複しています。", - "Dynamic_import_cannot_have_type_arguments_1326": "動的インポートに型引数を指定することはできません。", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "動的インポートの指定子の型は 'string' である必要がありますが、ここでは型 '{0}' が指定されています。", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "動的インポートは、'--module' フラグが 'es2022'、'es2020'、'esnext'、'commonjs'、'amd'、'system'、'umd'、'node12'、'nodenext' に設定されている場合にのみサポートされます。", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "動的インポートでは、引数として、モジュール指定子とオプションのアサーションのみを受け取ることができます", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "{0} 引数が必要ですが、{1} が指定されました。'Promise' の型引数に 'void' を含めましたか?", "Expected_0_type_arguments_but_got_1_2558": "{0} 個の型引数が必要ですが、{1} 個が指定されました。", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "{0} 型の引数が必要です。'@extends' タグで指定してください。", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "1 個の引数が必要ですが、0 個しかありませんでした。'new Promise()' では、引数なしで呼び出すことができる 'resolve' を生成するための JSDoc ヒントが必要です。", "Expected_at_least_0_arguments_but_got_1_2555": "最低でも {0} 個の引数が必要ですが、{1} 個指定されました。", "Expected_corresponding_JSX_closing_tag_for_0_17002": "'{0}' の対応する JSX 終了タグが必要です。", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "JSX フラグメントの対応する終了タグが必要です。", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "この構文には、'{1}' という名前のインポートされたヘルパーが必要ですが、'{0}' には存在しません。'{0}' のバージョンのアップグレードを検討してください。", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "この構文には、{2} パラメーターを持つ '{1}' という名前のインポートされたヘルパーが必要ですが、'{0}' にあるものと互換性がありません。'{0}' のバージョンをアップグレードすることをご検討ください。", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "この型パラメーターには、`extends object` 制約が必要な可能性があります。", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "この 'import' の使用は無効です。'import()' 呼び出しは書き込むことができますが、かっこが必要であり、型引数を指定することはできません。", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "トップレベルの 'await' 式は、'module' オプションが 'es2022'、'esnext'、'system'、または 'nodenext' に設定されていて、'target' オプションが 'es2017' 以上に設定されている場合にのみ使用できます。", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts ファイルのトップレベルの宣言は、'declare' または 'export' 修飾子で始める必要があります。", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "トップレベルの 'for await' ループは、'module' オプションが 'es2022'、'esnext'、'system'、または 'nodenext' に設定されていて、'target' オプションが 'es2017' 以上に設定されている場合にのみ使用できます。", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "型 '{0}' は Promise と互換性のあるコンストラクター値を参照しないため、ES5/ES3 において有効な非同期関数の戻り値の型ではありません。", "Type_0_is_not_an_array_type_2461": "型 '{0}' は配列型ではありません。", "Type_0_is_not_an_array_type_or_a_string_type_2495": "型 '{0}' は配列型でも文字列型でもありません。", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "型 '{0}' は配列型でも文字列型でもありません。反復子の反復を許可するには、コンパイラ オプション '--downlevelIteration' を使用します。", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "型 '{0}' は、配列型でも文字列型でもないか、反復子を返す '[Symbol.iterator]()' メソッドを持っていません。", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "型 '{0}' は、配列型ではないか、反復子を返す '[Symbol.iterator]()' メソッドを持っていません。", "Type_0_is_not_assignable_to_type_1_2322": "型 '{0}' を型 '{1}' に割り当てることはできません。", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "変数宣言リストを空にすることはできません。", "Variable_declaration_not_allowed_at_this_location_1440": "変数の宣言はこの場所では許可されていません。", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "ソースの位置 {0} にある可変個引数要素は、ターゲットの位置 {1} にある要素と一致しません。", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "分散注釈は、オブジェクト、関数、コンストラクター、およびマップされた型の型エイリアスでのみサポートされています。", "Version_0_6029": "バージョン {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "このファイルの詳細については、https://aka.ms/tsconfig をご覧ください", "WATCH_OPTIONS_6918": "ウォッチ オプション", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index c8743a2ee1214..7871694e7e553 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "값 없이 확인된 Promise에 'void' 추가", "Add_void_to_all_Promises_resolved_without_a_value_95144": "값 없이 확인된 모든 Promise에 'void' 추가", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "tsconfig.json 파일을 추가하면 TypeScript 파일과 JavaScript 파일이 둘 다 포함된 프로젝트를 정리하는 데 도움이 됩니다. 자세한 내용은 https://aka.ms/tsconfig를 참조하세요.", + "All_declarations_of_0_must_have_identical_constraints_2838": "'{0}'의 모든 선언에는 동일한 제약 조건이 있어야 합니다.", "All_declarations_of_0_must_have_identical_modifiers_2687": "'{0}'의 모든 선언에는 동일한 한정자가 있어야 합니다.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "'{0}'의 모든 선언에는 동일한 형식 매개 변수가 있어야 합니다.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "추상 메서드의 모든 선언은 연속적이어야 합니다.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "'{0}' 형식에 대한 인덱스 시그니처가 중복되었습니다.", "Duplicate_label_0_1114": "중복된 레이블 '{0}'입니다.", "Duplicate_property_0_2718": "중복 속성 '{0}'입니다.", - "Dynamic_import_cannot_have_type_arguments_1326": "동적 가져오기에는 형식 인수를 사용할 수 없습니다.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "동적 가져오기의 지정자는 'string' 형식이어야 하지만 여기에서 형식은 '{0}'입니다.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "동적 가져오기는 '--module' 플래그가 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12' 또는 'nodenext'로 설정된 경우에만 지원됩니다.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "동적 가져오기는 모듈 지정자와 선택적 어설션만 인수로 수락합니다.", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "{0}개 인수가 필요한데 {1}개를 가져왔습니다. 'void'를 'Promise'의 형식 인수에 포함하는 것을 잊으셨습니까?", "Expected_0_type_arguments_but_got_1_2558": "{0}개의 형식 인수가 필요한데 {1}개를 가져왔습니다.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "'@extends' 태그로 제공하는 예상되는 {0} 형식 인수입니다.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "1개의 인수가 필요하지만 0이 있습니다. 'new Promise()'는 인수 없이 호출할 수 있는 'resolve'를 생성하기 위해 JSDoc 힌트가 필요합니다.", "Expected_at_least_0_arguments_but_got_1_2555": "최소 {0}개의 인수가 필요한데 {1}개를 가져왔습니다.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "'{0}'에 해당하는 JSX 닫는 태그가 필요합니다.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "JSX 조각에 닫는 태그가 필요합니다.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "이 구문에는 '{0}'에 없는 '{1}'(이)라는 가져온 도우미가 필요합니다. '{0}'의 버전을 업그레이드하는 것이 좋습니다.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "이 구문에는 {2} 매개 변수가 포함된 '{1}'(이)라는 가져온 도우미가 필요하지만, 이 도우미는 '{0}'에 있는 도우미와 호환되지 않습니다. '{0}' 버전을 업그레이드하는 것이 좋습니다.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "이 형식 매개 변수에는 `extends object` 제약 조건이 필요할 수 있습니다.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "이 '가져오기' 사용은 유효하지 않습니다. 'import()' 호출을 작성할 수 있지만 괄호가 있어야 하며 유형 인수를 가질 수 없습니다.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "최상위 'await' 식은 'module' 옵션이 'es2022', 'esnext', 'system' 또는 'nodenext'로 설정되고 'target' 옵션이 'es2017' 이상으로 설정된 경우에만 허용됩니다.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 파일의 최상위 수준 선언은 'declare' 또는 'export' 한정자로 시작해야 합니다.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "최상위 'for await' 루프는 'module' 옵션이 'es2022', 'esnext', 'system' 또는 'nodenext'로 설정되고 'target' 옵션이 'es2017' 이상으로 설정된 경우에만 허용됩니다.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "'{0}' 형식은 Promise 호환 생성자 값을 참조하지 않으므로 ES5/ES3에서 유효한 비동기 함수 반환 형식이 아닙니다.", "Type_0_is_not_an_array_type_2461": "'{0}' 형식은 배열 형식이 아닙니다.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "'{0}' 형식은 배열 형식 또는 문자열 형식이 아닙니다.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "'{0}' 형식이 배열 형식 또는 문자열 형식이 아닙니다. 컴파일러 옵션 '-downlevelIteration'을 사용하여 반복기의 반복을 허용하세요.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "'{0}' 형식은 배열 형식 또는 문자열 형식이 아니거나, 반복기를 반환하는 '[Symbol.iterator]()' 메서드가 없습니다.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "'{0}' 형식은 배열 형식이 아니거나 반복기를 반환하는 '[Symbol.iterator]()' 메서드가 없습니다.", "Type_0_is_not_assignable_to_type_1_2322": "'{0}' 형식은 '{1}' 형식에 할당할 수 없습니다.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "변수 선언 목록은 비워 둘 수 없습니다.", "Variable_declaration_not_allowed_at_this_location_1440": "이 위치에서는 변수 선언을 사용할 수 없습니다.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "소스의 {0} 위치에 있는 가변 인자 요소가 대상의 {1} 위치에 있는 요소와 일치하지 않습니다.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "차이 주석은 개체, 함수, 생성자 및 매핑된 형식의 형식 별칭에서만 지원됩니다.", "Version_0_6029": "버전 {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "이 파일에 대해 자세히 알아보려면 https://aka.ms/tsconfig을 방문하세요.", "WATCH_OPTIONS_6918": "조사식 옵션", diff --git a/lib/lib.es2020.bigint.d.ts b/lib/lib.es2020.bigint.d.ts index 8fcda08ce24a0..a0ebccaf9ca77 100644 --- a/lib/lib.es2020.bigint.d.ts +++ b/lib/lib.es2020.bigint.d.ts @@ -693,6 +693,7 @@ interface DataView { * Gets the BigInt64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; @@ -700,6 +701,7 @@ interface DataView { * Gets the BigUint64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; @@ -707,8 +709,7 @@ interface DataView { * Stores a BigInt64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; @@ -716,8 +717,7 @@ interface DataView { * Stores a BigUint64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; } diff --git a/lib/lib.es2022.d.ts b/lib/lib.es2022.d.ts index 73558c81125bb..6d4283d28e2ef 100644 --- a/lib/lib.es2022.d.ts +++ b/lib/lib.es2022.d.ts @@ -21,5 +21,6 @@ and limitations under the License. /// /// /// +/// /// /// diff --git a/lib/lib.es2022.intl.d.ts b/lib/lib.es2022.intl.d.ts new file mode 100644 index 0000000000000..ff487a11c955c --- /dev/null +++ b/lib/lib.es2022.intl.d.ts @@ -0,0 +1,111 @@ +/*! ***************************************************************************** +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 { + + /** + * An object with some or all properties of the `Intl.Segmenter` constructor `options` parameter. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters) + */ + interface SegmenterOptions { + /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */ + localeMatcher?: "best fit" | "lookup" | undefined; + /** The type of input to be split */ + granularity?: "grapheme" | "word" | "sentence" | undefined; + } + + interface Segmenter { + /** + * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity. + * + * @param input - The text to be segmented as a `string`. + * + * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity. + */ + segment(input: string): Segments; + resolvedOptions(): ResolvedSegmenterOptions; + } + + interface ResolvedSegmenterOptions { + locale: string; + granularity: "grapheme" | "word" | "sentence"; + } + + interface Segments { + /** + * Returns an object describing the segment in the original string that includes the code unit at a specified index. + * + * @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`. + */ + containing(codeUnitIndex?: number): SegmentData; + + /** Returns an iterator to iterate over the segments. */ + [Symbol.iterator](): IterableIterator; + } + + interface SegmentData { + /** A string containing the segment extracted from the original input string. */ + segment: string; + /** The code unit index in the original input string at which the segment begins. */ + index: number; + /** The complete input string that was segmented. */ + input: string; + /** + * A boolean value only if granularity is "word"; otherwise, undefined. + * If granularity is "word", then isWordLike is true when the segment is word-like (i.e., consists of letters/numbers/ideographs/etc.); otherwise, false. + */ + isWordLike?: boolean; + } + + const Segmenter: { + prototype: Segmenter; + + /** + * Creates a new `Intl.Segmenter` object. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the `locales` argument, + * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters) + * with some or all options of `SegmenterOptions`. + * + * @returns [Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments) object. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter). + */ + new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: SegmenterOptions): Segmenter; + + /** + * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the `locales` argument, + * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf#parameters). + * with some or all possible options. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf) + */ + supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick): BCP47LanguageTag[]; + }; +} diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 27e77b45df3d5..d45132b5b429f 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -72,13 +72,13 @@ declare function decodeURIComponent(encodedURIComponent: string): string; /** * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. + * @param uri A value representing an unencoded URI. */ declare function encodeURI(uri: string): string; /** * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. + * @param uriComponent A value representing an unencoded URI component. */ declare function encodeURIComponent(uriComponent: string | number | boolean): string; @@ -1689,6 +1689,7 @@ interface DataView { * Gets the Float32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getFloat32(byteOffset: number, littleEndian?: boolean): number; @@ -1696,6 +1697,7 @@ interface DataView { * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getFloat64(byteOffset: number, littleEndian?: boolean): number; @@ -1710,12 +1712,14 @@ interface DataView { * Gets the Int16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getInt32(byteOffset: number, littleEndian?: boolean): number; @@ -1730,6 +1734,7 @@ interface DataView { * Gets the Uint16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getUint16(byteOffset: number, littleEndian?: boolean): number; @@ -1737,6 +1742,7 @@ interface DataView { * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getUint32(byteOffset: number, littleEndian?: boolean): number; @@ -1744,8 +1750,7 @@ interface DataView { * Stores an Float32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1753,8 +1758,7 @@ interface DataView { * Stores an Float64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1769,8 +1773,7 @@ interface DataView { * Stores an Int16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1778,8 +1781,7 @@ interface DataView { * Stores an Int32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1794,8 +1796,7 @@ interface DataView { * Stores an Uint16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1803,8 +1804,7 @@ interface DataView { * Stores an Uint32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index 3df0b95ffe7fa..33937c72a1c17 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Dodaj argument „void” do obiektu Promise rozwiązanego bez wartości", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Dodaj argument „void” do wszystkich obiektów Promise rozwiązanych bez wartości", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Dodanie pliku tsconfig.json pomoże w organizowaniu projektów, które zawierają pliki TypeScript i JavaScript. Dowiedz się więcej: https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Wszystkie deklaracje elementu „{0}” muszą mieć identyczne ograniczenia.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Wszystkie deklaracje elementu „{0}” muszą mieć identyczne modyfikatory.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Wszystkie deklaracje „{0}” muszą mieć identyczne parametry typu.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Wszystkie deklaracje metody abstrakcyjnej muszą występować obok siebie.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Zduplikowana sygnatura indeksu dla typu „{0}”.", "Duplicate_label_0_1114": "Zduplikowana etykieta „{0}”.", "Duplicate_property_0_2718": "Zduplikowana właściwość „{0}”.", - "Dynamic_import_cannot_have_type_arguments_1326": "Dynamiczny import nie może mieć argumentów typu.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Specyfikator dynamicznego importowania musi być typu „string”, ale określono typ „{0}”.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Dynamiczne importy są obsługiwane tylko wtedy, gdy flaga „--module” jest ustawiona na „es2020”, „es2022”, „esnext”, „commonjs”, „amd”, „system”, „umd”, „node12” lub „nodenext”.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Importy dynamiczne akceptują jako argumenty tylko specyfikator modułu i asercję opcjonalną", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "Oczekiwano {0} argumentów, ale otrzymano {1}. Czy zapomniano dołączyć wartość „void” w argumencie typu obiektu „Promise”?", "Expected_0_type_arguments_but_got_1_2558": "Oczekiwane argumenty typu: {0}, uzyskano: {1}.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Oczekiwano argumentów typu {0}; podaj je z tagiem „@extends”.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "Oczekiwano 1 argumentu, ale otrzymano 0. Element „new Promise()” wymaga wskazówki JSDoc, aby utworzyć element „resolve”, który można wywołać bez argumentów.", "Expected_at_least_0_arguments_but_got_1_2555": "Oczekiwane argumenty: co najmniej {0}, uzyskano: {1}.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Oczekiwano odpowiadającego tagu zamykającego kodu JSX dla elementu „{0}”.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Oczekiwano odpowiedniego tagu zamykającego dla fragmentu kodu JSX.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Ta składnia wymaga zaimportowanego pomocnika o nazwie „{1}”, który nie istnieje w elemencie „{0}”. Rozważ uaktualnienie wersji „{0}”.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Ta składnia wymaga zaimportowanego pomocnika o nazwie „{1}” z parametrami {2}, który nie jest zgodny z tym w elemencie „{0}”. Rozważ uaktualnienie wersji elementu „{0}”.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Ten parametr typu prawdopodobnie wymaga ograniczenia „extends object”.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "To użycie elementu „import” jest nieprawidłowe. Wywołania „import()” mogą być zapisywane, ale muszą mieć nawiasy i nie mogą mieć argumentów typu.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Wyrażenia „await” najwyższego poziomu są dozwolone tylko wtedy, gdy opcja „module” jest ustawiona na wartość „es2022”, „esnext”, „system” lub „nodenext”, a opcja „target” jest ustawiona na wartość „es2017” lub wyższą.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Deklaracje najwyższego poziomu w plikach .d.ts muszą rozpoczynać się od modyfikatora „declare” lub „export”.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Pętle najwyższego poziomu „for await” są dozwolone tylko wtedy, gdy opcja „module” jest ustawiona na wartość „es2022”, „esnext”, „system” lub „nodenext”, a opcja „target” jest ustawiona na wartość „es2017” lub wyższą.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Typ „{0}” nie jest prawidłowym zwracanym typem funkcji asynchronicznej w wersji ES5/ES3, ponieważ nie odwołuje się do wartości konstruktora zgodnej z elementem Promise.", "Type_0_is_not_an_array_type_2461": "Typ „{0}” nie jest typem tablicowym.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "Typ „{0}” nie jest typem tablicowym ani typem ciągu.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "Typ „{0}” nie jest typem tablicy ani typem ciągu. Użyj opcji kompilatora „--downlevelIteration”, aby zezwolić na iterowanie iteratorów.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "Typ „{0}” nie jest typem tablicy ani ciągu lub nie ma metody „[Symbol.iterator]()” zwracającej iterator.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "Typ „{0}” nie jest typem tablicy lub nie ma metody „[Symbol.iterator]()” zwracającej iterator.", "Type_0_is_not_assignable_to_type_1_2322": "Typu „{0}” nie można przypisać do typu „{1}”.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "Lista deklaracji zmiennych nie może być pusta.", "Variable_declaration_not_allowed_at_this_location_1440": "Deklaracja zmiennej jest niedozwolona w tej lokalizacji.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "Element ze zmienną liczbą argumentów na pozycji {0} w źródle nie jest zgodny z elementem na pozycji {1} w lokalizacji docelowej.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Adnotacje wariancji są obsługiwane tylko w aliasach typów obiektów, funkcji, konstruktorów i mapowanych typów.", "Version_0_6029": "Wersja {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Odwiedź https://aka.ms/tsconfig, aby dowiedzieć się więcej o tym pliku", "WATCH_OPTIONS_6918": "OPCJE OBSERWACJI", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index bc0657d6d0f5b..4407b6bf285fc 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -42,6 +42,7 @@ declare namespace ts.server.protocol { Rename = "rename", Saveto = "saveto", SignatureHelp = "signatureHelp", + FindSourceDefinition = "findSourceDefinition", Status = "status", TypeDefinition = "typeDefinition", ProjectInfo = "projectInfo", @@ -661,6 +662,9 @@ declare namespace ts.server.protocol { interface DefinitionAndBoundSpanRequest extends FileLocationRequest { readonly command: CommandTypes.DefinitionAndBoundSpan; } + interface FindSourceDefinitionRequest extends FileLocationRequest { + readonly command: CommandTypes.FindSourceDefinition; + } interface DefinitionAndBoundSpanResponse extends Response { readonly body: DefinitionInfoAndBoundSpan; } @@ -1821,6 +1825,7 @@ declare namespace ts.server.protocol { body?: CompletionInfo; } interface CompletionInfo { + readonly flags?: number; readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index c97d1fd697097..d476fb5d35b72 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Adicionar 'void' ao Promise resolvido sem um valor", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Adicionar 'void' a todos os Promises resolvidos sem um valor", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Adicionar um arquivo tsconfig.json ajudará a organizar projetos que contêm arquivos TypeScript e JavaScript. Saiba mais em https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Todas as declarações de '{0}' devem ter restrições idênticas.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Todas as declarações de '{0}' devem ter modificadores idênticos.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Todas as declarações de '{0}' devem ter parâmetros de tipo idênticos.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Todas as declarações de um método abstrato devem ser consecutivas.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Assinatura de índice duplicada para o tipo '{0}'.", "Duplicate_label_0_1114": "Rótulo '{0}' duplicado.", "Duplicate_property_0_2718": "Propriedade '{0}' duplicada.", - "Dynamic_import_cannot_have_type_arguments_1326": "A importação dinâmica não pode ter argumentos de tipo.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "O especificador da importação dinâmica deve ser do tipo 'string', mas aqui tem o tipo '{0}'.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Importações dinâmicas são suportadas apenas quando o sinalizador '--module' é definido como 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', ou 'nodenext'.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "As importações dinâmicas somente podem aceitar um especificador de módulo e uma asserção opcional como argumentos", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "{0} argumentos eram esperados, mas foram obtidos {1}. Você esqueceu de incluir 'void' no argumento de tipo para 'Promise'?", "Expected_0_type_arguments_but_got_1_2558": "{0} argumentos de tipo eram esperados, mas {1} foram obtidos.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Espera-se {0} argumentos de tipo; forneça esses recursos com uma marca \"@extends\".", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "Esperava 1 argumento, mas obteve 0. 'new Promise()' precisa de uma dica JSDoc para produzir um 'resolver' que pode ser chamado sem argumentos.", "Expected_at_least_0_arguments_but_got_1_2555": "Pelo menos {0} argumentos eram esperados, mas {1} foram obtidos.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Marca de fechamento de JSX correspondente esperada para '{0}'.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Marca de fechamento correspondente esperada para fragmento JSX.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Esta sintaxe requer um auxiliar importado chamado '{1}' que não existe em '{0}'. Considere atualizar sua versão do '{0}'.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Esta sintaxe exige um auxiliar importado nomeado como '{1}' com parâmetros {2}, o que não é compatível com o que está em '{0}'. Considere atualizar sua versão do '{0}'.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Esse parâmetro de tipo provavelmente precisa de uma restrição `extends object.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Este uso de 'importar' é inválido. Chamadas 'import()' podem ser escritas, mas devem ter parênteses e não podem ter argumentos de tipo.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Expressões de nível superior 'await' são permitidas apenas quando a opção 'module' está definida como 'es2022', 'esnext', 'system' ou 'nodenext' e a opção 'target' está definida como 'es2017 ou superior.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "As declarações de nível superior em arquivos .d.ts devem começar com um modificador 'declare' ou 'export'.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Loops de nível superior 'for await' são permitidos apenas quando a opção 'module' está definida como 'es2022', 'esnext', 'system' ou 'nodenext' e a opção 'target' está definida como 'es2017' ou superior.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "O tipo '{0}' não é um tipo de retorno de função assíncrona válido no ES5/ES3, pois não se refere ao valor construtor compatível com a Promessa.", "Type_0_is_not_an_array_type_2461": "O tipo '{0}' não é um tipo de matriz.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "O tipo '{0}' não é um tipo de matriz ou de cadeia de caracteres.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "O tipo '{0}' não é um tipo de matriz nem um tipo de cadeia de caracteres. Use a opção do compilador '--downlevelIteration' para permitir a iteração dos iteradores.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "O tipo '{0}' não é um tipo de matriz de um tipo de cadeia ou não tem um método '[Symbol.iterator]()' que retorna um iterador.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "O tipo '{0}' não é um tipo de matriz ou não tem um método '[Symbol.iterator]()' que retorna um iterador.", "Type_0_is_not_assignable_to_type_1_2322": "O tipo '{0}' não pode ser atribuído ao tipo '{1}'.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "A lista de declaração de variável não pode estar vazia.", "Variable_declaration_not_allowed_at_this_location_1440": "A declaração de variável não é permitida neste local.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "O elemento variádico na posição {0} na fonte não corresponde ao elemento na posição {1} no destino.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Só há suporte para anotações de variação em aliases do tipo para objetos, funções, construtores e tipos mapeados.", "Version_0_6029": "Versão {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Visite https://aka.ms/tsconfig para ler mais sobre este arquivo", "WATCH_OPTIONS_6918": "OPÇÕES DE INSPEÇÃO", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index a3cfd206042ef..62b79ea0c85dc 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Добавить \"void\" в Promise (обещание), разрешенное без значения", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Добавить \"void\" во все Promise (обещания), разрешенные без значения", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Добавление файла tsconfig.json поможет организовать проекты, содержащие файлы TypeScript и JavaScript. Дополнительные сведения: https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Все объявления \"{0}\" должны иметь одинаковые ограничения.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Все объявления \"{0}\" должны иметь одинаковые модификаторы.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Все объявления \"{0}\" должны иметь одинаковые параметры типа.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Все объявления абстрактных методов должны быть последовательными.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "Повторяющаяся сигнатура индекса для типа \"{0}\".", "Duplicate_label_0_1114": "Повторяющаяся метка \"{0}\".", "Duplicate_property_0_2718": "Повторяющееся свойство \"{0}\".", - "Dynamic_import_cannot_have_type_arguments_1326": "При динамическом импорте не могут использоваться аргументы типов.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Описатель динамического импорта должен иметь тип \"string\", но имеет тип \"{0}\".", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Динамический импорт поддерживаются только в том случае, если флагу \"--module\" присвоено значение \"es2020\", \"es2022\", \"esnext\", \"commonjs\", \"amd\", \"system\", \"umd\", \"node12\" или \"nodenext\".", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Динамические импорты могут принять спецификатор модуля и необязательное утверждение в качестве аргументов", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "Ожидаемое число аргументов — {0}, фактическое — {1}. Возможно, вы забыли указать void в аргументе типа в Promise?", "Expected_0_type_arguments_but_got_1_2558": "Ожидались аргументы типа {0}, получены: {1}.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "Ожидается аргументов типа: {0}. Укажите их с тегом \"@extends\".", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "Ожидался 1 аргумент, получено 0. Для \"new Promise()\" требуется указание JSDoc, чтобы создать \"resolve\" с возможностью вызова без аргументов.", "Expected_at_least_0_arguments_but_got_1_2555": "Ожидалось аргументов не меньше: {0}, получено: {1}.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "Ожидался соответствующий закрывающий тег JSX для \"{0}\".", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "Ожидался соответствующий закрывающий тег фрагмента JSX.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Для этого синтаксиса требуется импортированный вспомогательный объект с именем \"{1}\", который не существует в \"{0}\". Рекомендуется обновить версию \"{0}\".", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Для этого синтаксиса требуется импортированный вспомогательный объект с именем \"{1}\" и параметрами ({2}), который не совместим с объектом в \"{0}\". Попробуйте обновить версию \"{0}\".", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Возможно, для этого параметра типа требуется ограничение \"extends object\".", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Недопустимое использование \"import\". Можно записывать вызовы \"import()\", но у них должны быть скобки и не должно быть аргументов типа.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Выражения \"await\" верхнего уровня допускаются, только если параметру \"module\" присвоено значение \"es2022\", \"esnext\", \"system\" или \"nodenext\", а параметру \"target\" присвоено значение \"es2017\" или выше.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Объявления верхнего уровня в файлах .d.ts должны начинаться с модификатора \"declare\" или \"export\".", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Циклы \"for await\" верхнего уровня допускаются, только если параметру \"module\" присвоено значение \"es2022\", \"esnext\", \"system\" или \"nodenext\", а параметру \"target\" присвоено значение \"es2017\" или выше.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Тип \"{0}\" не является допустимым типом возвращаемого значения асинхронной функции в ES5/ES3, так как он не ссылается на значение конструктора, совместимое с Promise.", "Type_0_is_not_an_array_type_2461": "Тип \"{0}\" не является типом массива.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "Тип \"{0}\" не является типом массива или типом строки.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "Тип \"{0}\" не является типом строки или массива. Используйте параметр компилятора \"--downlevelIteration\", чтобы разрешить итерацию итераторов.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "{0} не является типом массива или строки или в нем нет метода [Symbol.iterator](), который возвращает итератор.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "{0} не является типом массива или в нем нет метода [Symbol.iterator](), который возвращает итератор.", "Type_0_is_not_assignable_to_type_1_2322": "Тип \"{0}\" не может быть назначен для типа \"{1}\".", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "Список объявлений переменной не может быть пустым.", "Variable_declaration_not_allowed_at_this_location_1440": "Объявление переменной в этом расположении запрещено.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "Элемент с переменным числом аргументов в позиции {0} в источнике не соответствует элементу в позиции {1} в целевом объекте.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Заметки вариантности поддерживаются только в псевдонимах типов для объектов, функций, конструкторов и сопоставленных типов.", "Version_0_6029": "Версия {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Дополнительные сведения об этом файле: https://aka.ms/tsconfig.", "WATCH_OPTIONS_6918": "ПАРАМЕТРЫ ПРОСМОТРА", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index acc881ff16f41..ba67b062b3c4f 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "Değer olmadan çözümlenen Promise'e 'void' ekle", "Add_void_to_all_Promises_resolved_without_a_value_95144": "Değer olmadan çözümlenen tüm Promise'lere 'void' ekle", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Bir tsconfig.json dosyası eklemek, hem TypeScript hem de JavaScript dosyaları içeren projeleri düzenlemenize yardımcı olur. Daha fazla bilgi edinmek için bkz. https://aka.ms/tsconfig.", + "All_declarations_of_0_must_have_identical_constraints_2838": "Tüm '{0}' bildirimleri, aynı kısıtlamalara sahip olmalıdır.", "All_declarations_of_0_must_have_identical_modifiers_2687": "Tüm '{0}' bildirimleri aynı değiştiricilere sahip olmalıdır.", "All_declarations_of_0_must_have_identical_type_parameters_2428": "Tüm '{0}' bildirimleri özdeş tür parametrelerine sahip olmalıdır.", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Soyut metoda ait tüm bildirimler ardışık olmalıdır.", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "'{0}' türü için yinelenen dizin imzası var.", "Duplicate_label_0_1114": "'{0}' etiketi yineleniyor.", "Duplicate_property_0_2718": "'{0}' özelliğini yineleyin.", - "Dynamic_import_cannot_have_type_arguments_1326": "Dinamik içeri aktarma, tür bağımsız değişkenleri içeremez.", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Dinamik içeri aktarmanın tanımlayıcısı 'string' türünde olmalıdır, ancak buradaki tür: '{0}'.", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "Dinamik içeri aktarmalar yalnızca '--module' bayrağı 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12' veya 'nodenext' olarak ayarlandığında desteklenir.", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "Dinamik içeri aktarmalar, bağımsız değişken olarak yalnızca bir modül tanımlayıcısı ve isteğe bağlı bir onay kabul edebilir", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "{0} bağımsız değişken bekleniyordu ancak {1} bağımsız değişken alındı. Tür bağımsız değişkeninizdeki 'void' operatörünü 'Promise'e eklemeyi mi unuttunuz?", "Expected_0_type_arguments_but_got_1_2558": "{0} tür bağımsız değişkeni bekleniyordu ancak {1} alındı.", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "{0} tür bağımsız değişkeni bekleniyordu; bunları bir '@extends' etiketiyle sağlayın.", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "1 bağımsız değişken bekleniyordu ancak 0 bağımsız değişken var. Bağımsız değişkenler olmadan çağrılabilen bir 'resolve' oluşturmak için 'new Promise()' çağrısında bir JSDoc ipucu bulunması gerekir.", "Expected_at_least_0_arguments_but_got_1_2555": "En az {0} bağımsız değişken bekleniyordu ancak {1} alındı.", "Expected_corresponding_JSX_closing_tag_for_0_17002": "'{0}' için ilgili JSX kapanış etiketi bekleniyor.", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "JSX parçasına karşılık gelen kapanış etiketi bekleniyordu.", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Bu söz dizimi, '{0}' içinde bulunmayan '{1}' adlı içeri aktarılmış bir yardımcı gerektirir. '{0}' sürümünüzü yükseltmeyi deneyin.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Bu söz dizimi, '{0}' içindeki yardımcı ile uyumlu olmayan, {2} parametreye sahip '{1}' adlı içeri aktarılan yardımcıyı gerektiriyor. '{0}' sürümünüzü yükseltmeyi düşünün.", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Bu tür parametresi için bir `nesneyi genişletir` kısıtlaması gerekiyor olabilir.", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "'import' çağrısının bu kullanımı geçersiz. 'import()' çağrıları yazılabilir ancak ayraç içermeleri gerekir ve tür bağımsız değişkenleri içeremezler.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "Üst düzey 'await' ifadelerine yalnızca 'module' seçeneği 'es2022', 'esnext', 'system' veya 'nodenext' olarak ayarlandığında ve 'target' seçeneği 'es2017' veya üzeri olarak ayarlandığında izin verilir.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts dosyalarındaki üst düzey bildirimler bir 'declare' veya 'export' değiştiricisi ile başlamalıdır.", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "Üst düzey 'for await' döngülerine yalnızca 'module' seçeneği 'es2022', 'esnext', 'system' veya 'nodenext' olarak ayarlandığında ve 'target' seçeneği 'es2017' veya üzeri olarak ayarlandığında izin verilir.", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "ES5/ES3 içindeki '{0}' türü, Promise ile uyumlu bir oluşturucu değerine başvurmadığından geçerli bir zaman uyumsuz işlev dönüş türü değil.", "Type_0_is_not_an_array_type_2461": "'{0}' türü bir dizi türü değil.", "Type_0_is_not_an_array_type_or_a_string_type_2495": "'{0}' türü, bir dizi türü veya dize türü değil.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "'{0}' türü bir dizi türü veya bir dize türü değil. Yineleyicilerin yinelenmesine izin vermek için '--downlevelIteration' derleyici seçeneğini kullanın.", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "'{0}' türü, bir dizi türü veya dize türü değil ya da bir yineleyici döndüren '[Symbol.iterator]()' metoduna sahip değil.", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "'{0}' türü, bir dizi türü değil ya da bir yineleyici döndüren '[Symbol.iterator]()' metoduna sahip değil.", "Type_0_is_not_assignable_to_type_1_2322": "'{0}' türü, '{1}' türüne atanamaz.", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "Değişken bildirim listesi boş olamaz.", "Variable_declaration_not_allowed_at_this_location_1440": "Bu konumda değişken bildirimine izin verilmiyor.", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "Kaynaktaki {0} konumunda bulunan değişen sayıda bağımsız değişken içeren öğe, hedefteki {1} konumunda bulunan öğeyle eşleşmiyor.", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "Varyans ek açıklamaları yalnızca nesne, işlev, oluşturucu ve eşlenen türler için tür diğer adlarında desteklenir.", "Version_0_6029": "Sürüm {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "Bu dosya hakkında daha fazla bilgi için https://aka.ms/tsconfig sayfasını ziyaret edin", "WATCH_OPTIONS_6918": "İZLEME SEÇENEKLERİ", diff --git a/lib/tsc.js b/lib/tsc.js index 14e3057f00f79..b13332a1df7d3 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.7"; - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "".concat(ts.versionMajorMinor, ".1-rc"); var NativeCollections; (function (NativeCollections) { var globals = typeof globalThis !== "undefined" ? globalThis : @@ -94,7 +94,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); var ts; @@ -1436,7 +1436,7 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; function noop(_) { } @@ -1486,7 +1486,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -1821,7 +1821,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; function matchedText(pattern, candidate) { @@ -2092,7 +2092,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2100,12 +2100,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2115,26 +2115,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2164,42 +2164,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2220,7 +2220,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; function formatEnum(value, enumObject, isFlags) { @@ -2238,7 +2238,7 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "" + result + (result ? "|" : "") + enumName; + result = "".concat(result).concat(result ? "|" : "").concat(enumName); remainingFlags &= ~enumValue; } } @@ -2347,7 +2347,7 @@ var ts; this.flags & 1 ? "FlowUnreachable" : "UnknownFlow"; var remainingFlags = this.flags & ~(2048 - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } }, @@ -2377,7 +2377,7 @@ var ts; __tsDebuggerDisplay: { value: function (defaultValue) { defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -2423,7 +2423,7 @@ var ts; var symbolHeader = this.flags & 33554432 ? "TransientSymbol" : "Symbol"; var remainingSymbolFlags = this.flags & ~33554432; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -2432,11 +2432,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var typeHeader = this.flags & 98304 ? "NullableType" : - this.flags & 384 ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : + this.flags & 384 ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : this.flags & 8192 ? "UniqueESSymbolType" : this.flags & 32 ? "EnumType" : - this.flags & 67359327 ? "IntrinsicType " + this.intrinsicName : + this.flags & 67359327 ? "IntrinsicType ".concat(this.intrinsicName) : this.flags & 1048576 ? "UnionType" : this.flags & 2097152 ? "IntersectionType" : this.flags & 4194304 ? "IndexType" : @@ -2455,7 +2455,7 @@ var ts; "ObjectType" : "Type"; var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~1343 : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, @@ -2489,11 +2489,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -2525,7 +2525,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -2569,10 +2569,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -2669,11 +2669,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -2895,7 +2895,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); var ts; @@ -3124,7 +3124,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3135,11 +3135,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -3207,7 +3207,7 @@ var ts; writeEvent("E", phase, name, args, undefined, endTime); } else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { @@ -3215,11 +3215,11 @@ var ts; if (mode === "server" && phase === "checkTypes") return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -3405,7 +3405,7 @@ var ts; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16"; ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var ModuleDetectionKind; @@ -3448,7 +3448,7 @@ var ts; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; - ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + ModuleKind[ModuleKind["Node16"] = 100] = "Node16"; ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); ts.commentPragmas = { @@ -3546,7 +3546,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -3970,7 +3970,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -3981,7 +3981,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -3997,7 +3997,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -4389,7 +4389,7 @@ var ts; var externalFileCounter = 0; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -4398,7 +4398,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -4414,7 +4414,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -4499,7 +4499,7 @@ var ts; } }; function invokeCallbackAndUpdateWatcher(createWatcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); callback("rename", ""); if (watcher) { watcher.close(); @@ -4516,7 +4516,7 @@ var ts; } } if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -4528,7 +4528,7 @@ var ts; } catch (e) { hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -5442,6 +5442,7 @@ var ts; _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), @@ -5453,10 +5454,10 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), - Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -5471,7 +5472,7 @@ var ts; 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_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_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5502,7 +5503,7 @@ var ts; await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -5554,7 +5555,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), - Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), @@ -5572,7 +5573,7 @@ var ts; Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), - Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."), + Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."), resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), @@ -5583,7 +5584,7 @@ var ts; An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), - auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), @@ -5592,7 +5593,8 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), - This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -5843,7 +5845,6 @@ var ts; A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), - 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."), Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), 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."), @@ -5901,6 +5902,7 @@ var ts; _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6056,6 +6058,7 @@ var ts; This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), @@ -6069,8 +6072,8 @@ var ts; Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), @@ -6181,6 +6184,7 @@ var ts; This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6736,7 +6740,6 @@ var ts; This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), - JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -7236,7 +7239,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -9751,7 +9754,7 @@ var ts; : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { @@ -10850,11 +10853,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -10931,7 +10934,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -11032,7 +11035,7 @@ var ts; ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -11049,10 +11052,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -11208,7 +11211,7 @@ var ts; ts.getScriptTargetFeatures = getScriptTargetFeatures; function getLiteralText(node, sourceFile, flags) { var _a; - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } switch (node.kind) { @@ -11251,7 +11254,7 @@ var ts; } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { @@ -11334,7 +11337,7 @@ var ts; } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isCommonJSContainingModuleKind(kind) { - return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext; } function isEffectiveExternalModule(node, compilerOptions) { return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); @@ -11443,6 +11446,10 @@ var ts; } } ts.isAnyImportSyntax = isAnyImportSyntax; + function isAnyImportOrBareOrAccessedRequire(node) { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { case 266: @@ -12673,17 +12680,13 @@ var ts; if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && + if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && (initializer.expression.kind === 108 || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - var nameOrArgument = getNameOrArgument(initializer); - if (ts.isPrivateIdentifier(nameOrArgument)) { - ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -12873,14 +12876,14 @@ var ts; } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { - var _a, _b, _c; + var _a, _b; switch (node.kind) { case 254: - return node.initializer.arguments[0].text; + return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; case 266: - return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); case 265: - return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); } @@ -13353,24 +13356,31 @@ var ts; return parent.propertyName === node; case 275: case 285: + case 279: + case 280: + case 281: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 265 || + if (node.kind === 265 || node.kind === 264 || node.kind === 267 && !!node.name || node.kind === 268 || node.kind === 274 || node.kind === 270 || node.kind === 275 || - node.kind === 271 && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 && isAliasableExpression(node.parent.right) || - node.kind === 297 || - node.kind === 296 && isAliasableExpression(node.initializer); + node.kind === 271 && exportAssignmentIsAlias(node)) { + return true; + } + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) + && ts.isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === 63 + && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { @@ -13381,6 +13391,7 @@ var ts; case 275: case 271: case 265: + case 274: return node.parent; case 161: do { @@ -13607,11 +13618,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -14042,6 +14053,10 @@ var ts; return indentStrings[1].length; } ts.getIndentSize = getIndentSize; + function isNightly() { + return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders"); + } + ts.isNightly = isNightly; function createTextWriter(newLine) { var output; var indent; @@ -14268,6 +14283,13 @@ var ts; ".d.ts"; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; + function getPossibleOriginalInputExtensionForExtension(path) { + return ts.fileExtensionIsOneOf(path, [".d.mts", ".mjs", ".mts"]) ? [".mts", ".mjs"] : + ts.fileExtensionIsOneOf(path, [".d.cts", ".cjs", ".cts"]) ? [".cts", ".cjs"] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json"] : + [".tsx", ".ts", ".jsx", ".js"]; + } + ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { return options.outFile || options.out; } @@ -14315,10 +14337,10 @@ var ts; return ts.combinePaths(newDirPath, sourceFilePath); } ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) { diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } ts.writeFile = writeFile; function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) { @@ -14880,6 +14902,11 @@ var ts; (node.parent.kind === 206 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfAccessExpression(node) { + return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { return ts.isQualifiedName(node.parent) && node.parent.right === node || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -15440,6 +15467,38 @@ var ts; return expr; } ts.getLeftmostAccessExpression = getLeftmostAccessExpression; + function forEachNameInAccessChainWalkingLeft(name, action) { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + function walkAccessExpression(access) { + if (access.kind === 206) { + var res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === 207) { + if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { + var res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + return undefined; + } + } + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (ts.isIdentifier(access.expression)) { + return action(access.expression); + } + return undefined; + } + } + ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { @@ -15802,7 +15861,7 @@ var ts; checks.push(isFileModuleFromUsingJSXTag); } var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } var combined_1 = ts.or.apply(void 0, checks); @@ -15813,7 +15872,7 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node12 && 7) || + (compilerOptions.module === ts.ModuleKind.Node16 && 9) || (compilerOptions.module === ts.ModuleKind.NodeNext && 99) || 0; } @@ -15831,8 +15890,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -15857,7 +15916,7 @@ var ts; case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; default: @@ -15882,7 +15941,7 @@ var ts; return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; } @@ -15950,7 +16009,7 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { @@ -16048,15 +16107,15 @@ var ts; } var wildcardCharCodes = [42, 63]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { singleAsteriskRegexFragment: "[^/]*", - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -16074,9 +16133,9 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -16094,7 +16153,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -16160,7 +16219,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -16297,6 +16356,7 @@ var ts; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"]]; var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json"]], false); + ts.supportedDeclarationExtensions = [".d.ts", ".d.cts", ".d.mts"]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -16405,7 +16465,7 @@ var ts; ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -16885,6 +16945,11 @@ var ts; return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; + function getParameterTypeNode(parameter) { + var _a; + return parameter.kind === 340 ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + } + ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); var ts; (function (ts) { @@ -21011,7 +21076,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(305); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -21639,7 +21704,7 @@ var ts; case 328: return "augments"; case 329: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; @@ -21966,7 +22031,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -25123,7 +25188,7 @@ var ts; function parseIsolatedEntityName(content, languageVersion) { initializeState("", content, languageVersion, undefined, 1); nextToken(); - var entityName = parseEntityName(true, false); + var entityName = parseEntityName(true); var isInvalid = token() === 1 && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; @@ -25695,7 +25760,7 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; @@ -26404,6 +26469,7 @@ var ts; var startPos = scanner.getStartPos(); var result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result); @@ -26453,7 +26519,7 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) { + function parseEntityName(allowReservedWords, diagnosticMessage) { var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); @@ -26463,7 +26529,7 @@ var ts; break; } dotPos = getNodePos(); - entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos); + entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false)), pos); } return entity; } @@ -26566,7 +26632,7 @@ var ts; return finishNode(node, pos); } function parseEntityNameOfTypeReference() { - return parseEntityName(true, false, ts.Diagnostics.Type_expected); + return parseEntityName(true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) { @@ -26680,8 +26746,8 @@ var ts; function parseTypeQuery() { var pos = getNodePos(); parseExpected(112); - var entityName = parseEntityName(true, true); - var typeArguments = tryParseTypeArguments(); + var entityName = parseEntityName(true); + var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } function parseTypeParameter() { @@ -27515,10 +27581,10 @@ var ts; setDecoratorContext(false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(false); + var expr = parseAssignmentExpressionOrHigher(); var operatorToken; while ((operatorToken = parseOptionalToken(27))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(false), pos); + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { setDecoratorContext(true); @@ -27526,23 +27592,23 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63) ? parseAssignmentExpressionOrHigher(false) : undefined; + return parseOptional(63) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) { + function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { return parseYieldExpression(); } - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } var pos = getNodePos(); var expr = parseBinaryExpressionOrHigher(0); if (expr.kind === 79 && token() === 38) { - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, undefined); + return parseSimpleArrowFunctionExpression(pos, expr, undefined); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } return parseConditionalExpressionRest(expr, pos); } @@ -27564,30 +27630,30 @@ var ts; nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 41 || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41), parseAssignmentExpressionOrHigher(false)), pos); + return finishNode(factory.createYieldExpression(parseOptionalToken(41), parseAssignmentExpressionOrHigher()), pos); } else { return finishNode(factory.createYieldExpression(undefined, undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, disallowReturnTypeInArrowFunction, asyncModifier) { + function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration(undefined, undefined, undefined, identifier, undefined, undefined, undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); var equalsGreaterThanToken = parseExpectedToken(38); - var body = parseArrowFunctionExpressionBody(!!asyncModifier, disallowReturnTypeInArrowFunction); + var body = parseArrowFunctionExpressionBody(!!asyncModifier); var node = factory.createArrowFunction(asyncModifier, undefined, parameters, undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); if (triState === 0) { return undefined; } return triState === 1 ? - parseParenthesizedArrowFunctionExpression(true, false) : - tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); }); + parseParenthesizedArrowFunctionExpression(true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } function isParenthesizedArrowFunctionExpression() { if (token() === 20 || token() === 29 || token() === 131) { @@ -27681,24 +27747,24 @@ var ts; return 2; } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function parsePossibleParenthesizedArrowFunctionExpression() { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(false, disallowReturnTypeInArrowFunction); + var result = parseParenthesizedArrowFunctionExpression(false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseAsyncSimpleArrowFunctionExpression() { if (token() === 131) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, asyncModifier); + return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); } } return undefined; @@ -27716,7 +27782,7 @@ var ts; } return 0; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity, disallowReturnTypeInArrowFunction) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); @@ -27744,9 +27810,6 @@ var ts; return undefined; } } - if (disallowReturnTypeInArrowFunction && token() === 58) { - return undefined; - } var type = parseReturnType(58, false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; @@ -27762,12 +27825,12 @@ var ts; var lastToken = token(); var equalsGreaterThanToken = parseExpectedToken(38); var body = (lastToken === 38 || lastToken === 18) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) : parseIdentifier(); var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync, disallowReturnTypeInArrowFunction) { + function parseArrowFunctionExpressionBody(isAsync) { if (token() === 18) { return parseFunctionBlock(isAsync ? 2 : 0); } @@ -27781,8 +27844,8 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }) - : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } @@ -27792,8 +27855,8 @@ var ts; return leftOperand; } var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(true); }), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(true) + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher() : createMissingNode(79, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos); } function parseBinaryExpressionOrHigher(precedence) { @@ -28386,29 +28449,9 @@ var ts; case 20: case 14: case 15: - case 27: - case 24: - case 28: - case 21: - case 23: - case 58: - case 26: - case 57: - case 34: - case 36: - case 35: - case 37: - case 55: - case 56: - case 60: - case 52: - case 50: - case 51: - case 19: - case 1: return true; } - return false; + return !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { @@ -28464,13 +28507,13 @@ var ts; function parseSpreadElement() { var pos = getNodePos(); parseExpected(25); - var expression = parseAssignmentExpressionOrHigher(false); + var expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { return token() === 25 ? parseSpreadElement() : token() === 27 ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(false); + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -28488,7 +28531,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); if (parseOptionalToken(25)) { - var expression = parseAssignmentExpressionOrHigher(false); + var expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); @@ -28511,13 +28554,13 @@ var ts; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58); if (isShorthandPropertyAssignment) { var equalsToken = parseOptionalToken(63); - var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(false); }) : undefined; + var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); node.equalsToken = equalsToken; } else { parseExpected(58); - var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(false); }); + var initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } node.decorators = decorators; @@ -28677,7 +28720,7 @@ var ts; } var node; if (awaitToken ? parseExpected(160) : parseOptional(160)) { - var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(false); }); + var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } @@ -29715,7 +29758,7 @@ var ts; var pos = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10); parseExpected(58); - var value = parseAssignmentExpressionOrHigher(false); + var value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { @@ -29765,7 +29808,7 @@ var ts; function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false, false); + : parseEntityName(false); } function parseExternalModuleReference() { var pos = getNodePos(); @@ -29909,7 +29952,7 @@ var ts; else { parseExpected(88); } - var expression = parseAssignmentExpressionOrHigher(false); + var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -29947,7 +29990,7 @@ var ts; var pos = getNodePos(); var hasBrace = parseOptional(18); var p2 = getNodePos(); - var entityName = parseEntityName(false, false); + var entityName = parseEntityName(false); while (token() === 80) { reScanHashToken(); nextTokenJSDoc(); @@ -30349,7 +30392,7 @@ var ts; skipWhitespace(); var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(true, false) + ? parseEntityName(true) : undefined; if (name) { while (token() === 80) { @@ -30655,7 +30698,8 @@ var ts; if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + var end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -31134,7 +31178,7 @@ var ts; IncrementalParser.createSyntaxCursor = createSyntaxCursor; })(IncrementalParser || (IncrementalParser = {})); function isDeclarationFileName(fileName) { - return ts.fileExtensionIsOneOf(fileName, [".d.ts", ".d.mts", ".d.cts"]); + return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions); } ts.isDeclarationFileName = isDeclarationFileName; function parseResolutionMode(mode, pos, end, reportDiagnostic) { @@ -31255,7 +31299,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } @@ -31436,6 +31480,7 @@ var ts; ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -31754,7 +31799,7 @@ var ts; es2020: ts.ModuleKind.ES2020, es2022: ts.ModuleKind.ES2022, esnext: ts.ModuleKind.ESNext, - node12: ts.ModuleKind.Node12, + node16: ts.ModuleKind.Node16, nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -32103,7 +32148,7 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, - node12: ts.ModuleResolutionKind.Node12, + node16: ts.ModuleResolutionKind.Node16, nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -32566,7 +32611,7 @@ var ts; affectsModuleResolution: true, description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: ts.Diagnostics.Language_and_Environment, - defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true); @@ -32692,8 +32737,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } function parseCustomTypeOption(opt, value, errors) { return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); @@ -33410,10 +33455,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -33451,19 +33496,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -33471,24 +33516,24 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -33841,7 +33886,7 @@ var ts; if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -34037,7 +34082,7 @@ var ts; if (ts.fileExtensionIs(file, ".json")) { if (!jsonOnlyIncludeRegexes) { var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -34265,7 +34310,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -34318,6 +34363,7 @@ var ts; Extensions[Extensions["Json"] = 2] = "Json"; Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; + Extensions[Extensions["TsOnly"] = 5] = "TsOnly"; })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { @@ -34326,7 +34372,7 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { var _a; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -34334,7 +34380,8 @@ var ts; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations: failedLookupLocations + failedLookupLocations: failedLookupLocations, + resolutionDiagnostics: diagnostics }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -34410,7 +34457,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -34511,11 +34558,22 @@ var ts; } var failedLookupLocations = []; var features = getDefaultNodeResolutionFeatures(options); - if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions }; + var diagnostics = []; + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -34534,7 +34592,7 @@ var ts; isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result); if (traceEnabled) traceResult(result); @@ -34598,7 +34656,7 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getDefaultNodeResolutionFeatures(options) { - return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -34611,6 +34669,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ts.emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: ts.noop }; return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { @@ -34784,7 +34844,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -34817,7 +34877,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -34911,8 +34971,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -34932,8 +34992,8 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName); switch (moduleResolution) { - case ts.ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ts.ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ts.ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -34945,10 +35005,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -35078,7 +35138,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -35091,12 +35151,12 @@ var ts; NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; - NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default"; + NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default"; NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault"; NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); - function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { - return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); } function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -35114,13 +35174,32 @@ var ts; return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + var extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) + extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) + extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; + var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + var diagnostics = []; var state = { compilerOptions: compilerOptions, host: host, @@ -35128,10 +35207,12 @@ var ts; failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -35184,7 +35265,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -35273,9 +35354,9 @@ var ts; } } function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts", ".d.cts", ".d.mts"])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) { var result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts", ".d.cts", ".d.mts"], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; + return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } @@ -35303,20 +35384,22 @@ var ts; default: return tryExtension(".d.ts"); } case Extensions.TypeScript: + case Extensions.TsOnly: + var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { case ".mjs": case ".mts": case ".d.mts": - return tryExtension(".mts") || tryExtension(".d.mts"); + return tryExtension(".mts") || (useDts ? tryExtension(".d.mts") : undefined); case ".cjs": case ".cts": case ".d.cts": - return tryExtension(".cts") || tryExtension(".d.cts"); + return tryExtension(".cts") || (useDts ? tryExtension(".d.cts") : undefined); case ".json": candidate += ".json"; - return tryExtension(".d.ts"); + return useDts ? tryExtension(".d.ts") : undefined; default: - return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts"); + return tryExtension(".ts") || tryExtension(".tsx") || (useDts ? tryExtension(".d.ts") : undefined); } case Extensions.JavaScript: switch (originalExtension) { @@ -35390,6 +35473,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features: features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: ts.noop }; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); @@ -35469,6 +35554,8 @@ var ts; packageJsonInfoCache: packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: ts.noop }; var parts = ts.getPathComponents(fileName); parts.pop(); @@ -35530,6 +35617,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -35592,14 +35680,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" || extension === ".jsx"; + return extension === ".js" || extension === ".jsx" || extension === ".mjs" || extension === ".cjs"; case Extensions.TSConfig: case Extensions.Json: return extension === ".json"; case Extensions.TypeScript: - return extension === ".ts" || extension === ".tsx" || extension === ".d.ts"; + return extension === ".ts" || extension === ".tsx" || extension === ".mts" || extension === ".cts" || extension === ".d.ts" || extension === ".d.mts" || extension === ".d.cts"; + case Extensions.TsOnly: + return extension === ".ts" || extension === ".tsx" || extension === ".mts" || extension === ".cts"; case Extensions.DtsOnly: - return extension === ".d.ts"; + return extension === ".d.ts" || extension === ".d.mts" || extension === ".d.cts"; } } function parsePackageName(moduleName) { @@ -35634,7 +35724,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -35740,7 +35830,6 @@ var ts; function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { return loadModuleFromTargetImportOrExport; function loadModuleFromTargetImportOrExport(target, subpath, pattern) { - var _a, _b; if (typeof target === "string") { if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { if (state.traceEnabled) { @@ -35775,13 +35864,16 @@ var ts; } return toSearchResult(undefined); } - var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) + return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, false, state))); } else if (typeof target === "object" && target !== null) { if (!Array.isArray(target)) { - for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { - var key = _c[_i]; + for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) { + var key = _a[_i]; if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { var subTarget = target[key]; var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); @@ -35799,8 +35891,8 @@ var ts; } return toSearchResult(undefined); } - for (var _d = 0, target_2 = target; _d < target_2.length; _d++) { - var elem = target_2[_d]; + for (var _b = 0, target_2 = target; _b < target_2.length; _b++) { + var elem = target_2[_b]; var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); if (result) { return result; @@ -35818,6 +35910,94 @@ var ts; trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(undefined); + function toAbsolutePath(path) { + var _a, _b; + if (path === undefined) + return path; + return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a))); + } + function combineDirectoryPath(root, dir) { + return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir)); + } + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) { + var _a, _b, _c, _d; + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) { + var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames }); + var commonSourceDirGuesses = []; + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts")); + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + var fragment = ts.ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + var parts = ts.getPathComponents(fragment); + parts.pop(); + var commonDir_1 = ts.getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir_1); + fragment = ts.ensureTrailingDirectorySeparator(commonDir_1); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(ts.createCompilerDiagnostic(isImports + ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, packagePath)); + } + for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) { + var commonSourceDirGuess = commonSourceDirGuesses_1[_i]; + var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) { + var candidateDir = candidateDirectories_1[_e]; + if (ts.startsWith(finalPath, candidateDir)) { + var pathFragment = finalPath.slice(candidateDir.length + 1); + var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); + var jsAndDtsExtensions = [".mjs", ".cjs", ".js", ".json", ".d.mts", ".d.cts", ".d.ts"]; + for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { + var ext = jsAndDtsExtensions_1[_f]; + if (ts.fileExtensionIs(possibleInputBase, ext)) { + var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) { + var possibleExt = inputExts_1[_g]; + var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, false, state))); + } + } + } + } + } + } + } + } + return undefined; + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) { + var _a, _b; + var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess; + var candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } function isApplicableVersionedTypesKey(conditions, key) { @@ -35952,7 +36132,7 @@ var ts; return mangled; } function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; function mangleScopedPackageName(packageName) { @@ -35992,10 +36172,11 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -36031,9 +36212,10 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; function toSearchResult(value) { @@ -36278,7 +36460,7 @@ var ts; if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } if (name.kind === 162) { var nameExpression = name.expression; @@ -36327,7 +36509,7 @@ var ts; case 317: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); case 164: - ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: ".concat(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; @@ -36393,7 +36575,7 @@ var ts; } var relatedInformation_1 = []; if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) { - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -37492,6 +37674,7 @@ var ts; case 261: case 259: case 195: + case 176: return 1 | 32; case 305: return 1 | 4 | 32; @@ -37509,7 +37692,6 @@ var ts; case 317: case 179: case 175: - case 176: case 180: case 170: return 1 | 4 | 32 | 8; @@ -38217,7 +38399,7 @@ var ts; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { @@ -39512,6 +39694,7 @@ var ts; var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); + var numericStringType = getTemplateLiteralType(["", ""], [numberType]); var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; }); var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; }); var uniqueLiteralType = createIntrinsicType(131072, "never"); @@ -39955,7 +40138,7 @@ var ts; if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -41330,27 +41513,27 @@ var ts; function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol) { var links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } return undefined; @@ -41643,16 +41826,13 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference); } - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json") { - error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } return getMergedSymbol(sourceFile.symbol); } @@ -41696,7 +41876,7 @@ var ts; var tsExtension = ts.tryExtractTSExtension(moduleReference); var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 || moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -41713,17 +41893,17 @@ var ts; ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); var suggestedExt = (_h = suggestedExtensions.find(function (_a) { var actualExt = _a[0], _importExt = _a[1]; return host.fileExists(absoluteRef_1 + actualExt); })) === null || _h === void 0 ? void 0 : _h[1]; if (suggestedExt) { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -42106,7 +42286,7 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol) { return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol)); @@ -42260,7 +42440,7 @@ var ts; var links = getSymbolLinks(symbol); var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -42937,13 +43117,27 @@ var ts; return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & 4 && type.root.isDistributive && !(type.checkType.flags & 262144)) { + var newParam = createTypeParameter(createSymbol(262144, "T")); + var name = typeParameterToName(newParam, context); + var newTypeVariable = ts.factory.createTypeReferenceNode(name); + context.approximateLength += 37; + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var saveInferTypeParameters_1 = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters_1; + var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143)), ts.factory.createKeywordTypeNode(143)); + } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } function typeToTypeNodeOrCircularityElision(type) { @@ -43050,7 +43244,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -43311,7 +43505,7 @@ var ts; } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined)); + typeElements.push(ts.factory.createPropertySignature(undefined, "... ".concat(properties.length - i, " more ..."), undefined, undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -43419,7 +43613,7 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } @@ -43432,7 +43626,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -43587,9 +43781,6 @@ var ts; if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & 1073741824) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, 524288); - } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768; @@ -43792,7 +43983,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -43809,7 +44000,7 @@ var ts; var targetFile = ts.getSourceFileOfModule(chain[0]); var specifier = void 0; var assertion = void 0; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) { specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext); assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([ @@ -43822,7 +44013,7 @@ var ts; } if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); if (specifier.indexOf("/node_modules/") >= 0) { @@ -43956,7 +44147,7 @@ var ts; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -44096,7 +44287,7 @@ var ts; var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_6) { return result_6; @@ -44113,6 +44304,16 @@ var ts; context.flags = oldFlags; return result; } + function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { + var typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, 524288) === typeFromTypeNode; + } + return false; + } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -44238,7 +44439,7 @@ var ts; function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -45051,7 +45252,7 @@ var ts; } return results_1; } - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -45121,7 +45322,7 @@ var ts; if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, undefined, typeToTypeNodeHelper(staticType, context)) ], 2)); @@ -45166,7 +45367,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -45272,15 +45473,15 @@ var ts; if (nameType.flags & 384) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34) + "\""; + return "\"".concat(ts.escapeString(name, 34), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } if (nameType.flags & 8192) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -45966,7 +46167,7 @@ var ts; } } var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types; - type = getUnionType(sourceTypes, 2); + type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, false, definedInMethod && !definedInConstructor)); @@ -47697,7 +47898,7 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } @@ -47856,7 +48057,8 @@ var ts; if (symbol === globalThisSymbol) { var varsOnly_1 = new ts.Map(); members.forEach(function (p) { - if (!(p.flags & 418)) { + var _a; + if (!(p.flags & 418) && !(p.flags & 512 && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -48352,8 +48554,9 @@ var ts; return circularConstraintType; } var result = void 0; - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + var identity_1 = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) { + stack.push(identity_1); result = computeBaseConstraint(getSimplifiedType(t, false)); stack.pop(); } @@ -48479,7 +48682,7 @@ var ts; var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -48788,7 +48991,7 @@ var ts; function isApplicableIndexType(source, target) { return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & 128) && ts.isNumericLiteralName(source.value); + target === numberType && (source === numericStringType || !!(source.flags & 128) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { if (type.flags & 3670016) { @@ -49421,7 +49624,7 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; @@ -49584,7 +49787,7 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { var identifier = name.kind === 161 ? name.right : @@ -49595,7 +49798,7 @@ var ts; var parentSymbol = name.kind === 161 ? getUnresolvedSymbolForEntityName(name.left) : name.kind === 206 ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { unresolvedSymbols.set(path, result = createSymbol(524288, text, 1048576)); @@ -49661,7 +49864,7 @@ var ts; if (substitute.flags & 3 || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; @@ -49694,6 +49897,18 @@ var ts; constraints = ts.append(constraints, constraint); } } + else if (type.flags & 262144 && parent.kind === 195 && node === parent.type) { + var mappedType = getTypeFromTypeNode(parent); + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + var typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + var constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = ts.append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; @@ -50508,9 +50723,9 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); + origin.flags & 1048576 ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { @@ -50580,7 +50795,7 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 && includes & 128 || + var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) || t.flags & 8 && includes & 256 || t.flags & 64 && includes & 2048 || t.flags & 4096 && includes & 8192; @@ -50703,7 +50918,7 @@ var ts; if (!strictNullChecks && includes & 98304) { return includes & 32768 ? undefinedType : nullType; } - if (includes & 4 && includes & 128 || + if (includes & 4 && includes & (128 | 134217728 | 268435456) || includes & 8 && includes & 256 || includes & 64 && includes & 2048 || includes & 4096 && includes & 8192) { @@ -50968,7 +51183,7 @@ var ts; if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -51039,7 +51254,7 @@ var ts; return str; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -51340,8 +51555,11 @@ var ts; return type[cache] = elementType; } } - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + if (isGenericMappedType(objectType)) { + var nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + } } return type[cache] = type; } @@ -51974,7 +52192,7 @@ var ts; function createUniqueESSymbolType(symbol) { var type = createType(8192); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -52368,7 +52586,7 @@ var ts; if (!type.declaration.nameType) { var constraint = void 0; if (isArrayType(t) || t.flags & 1 && findResolutionCycleStartIndex(typeVariable, 4) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -53503,20 +53721,20 @@ var ts; switch (msg.code) { case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; if (path.length === 0) { - path = "" + str; + path = "".concat(str); } else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -53543,7 +53761,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -53556,7 +53774,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -53663,7 +53881,7 @@ var ts; } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -53759,7 +53977,7 @@ var ts; unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); if (result_7 && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) { + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) { inPropertyCheck = true; result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags); inPropertyCheck = false; @@ -53774,7 +53992,6 @@ var ts; return 0; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { - var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -53813,9 +54030,6 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & 8650752 && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) { - associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { @@ -54445,17 +54659,17 @@ var ts; if (sourceFlags & 8650752) { if (!(sourceFlags & 8388608 && targetFlags & 8388608)) { var constraint = getConstraintOfType(source); - if (!strictNullChecks && (!constraint || (sourceFlags & 262144 && constraint.flags & 1))) { + if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) { if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (constraint && (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -54578,7 +54792,7 @@ var ts; return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3, reportErrors); } @@ -54872,7 +55086,7 @@ var ts; } var result = -1; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { return 0; } @@ -55453,7 +55667,7 @@ var ts; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); function getTypeReferenceId(type, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; @@ -55489,7 +55703,7 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } function forEachProperty(prop, callback) { if (ts.getCheckFlags(prop) & 6) { @@ -55530,12 +55744,12 @@ var ts; function isDeeplyNestedType(type, stack, depth, maxDepth) { if (maxDepth === void 0) { maxDepth = 3; } if (depth >= maxDepth) { - var identity_1 = getRecursionIdentity(type); + var identity_2 = getRecursionIdentity(type); var count = 0; var lastTypeId = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (getRecursionIdentity(t) === identity_1) { + if (getRecursionIdentity(t) === identity_2) { if (t.id >= lastTypeId) { count++; if (count >= maxDepth) { @@ -55719,6 +55933,9 @@ var ts; function isReadonlyArrayType(type) { return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType; } + function isArrayOrTupleType(type) { + return isArrayType(type) || isTupleType(type); + } function isMutableArrayOrTuple(type) { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; } @@ -56116,7 +56333,7 @@ var ts; else if (type.flags & 2097152) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -56142,7 +56359,7 @@ var ts; } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { @@ -57044,7 +57261,7 @@ var ts; } } if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); @@ -57333,10 +57550,10 @@ var ts; case 79: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } case 108: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); case 230: case 212: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -59347,7 +59564,7 @@ var ts; if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; if (parent.kind === 254 && ts.getCombinedNodeFlags(declaration) & 2 || parent.kind === 164) { - var links = getNodeLinks(location); + var links = getNodeLinks(parent); if (!(links.flags & 268435456)) { links.flags |= 268435456; var parentType = getTypeForBindingElementParent(parent, 0); @@ -60697,7 +60914,7 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } @@ -61235,6 +61452,7 @@ var ts; } } else { + error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -61919,7 +62137,9 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 && node.parent.kind === 299)) || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -63046,8 +63266,14 @@ var ts; var parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && ts.isInJSFile(node)) { + return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + var error = hasRestParameter + ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : ts.Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); @@ -63123,6 +63349,7 @@ var ts; var args = getEffectiveCallArguments(node); var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0; + argCheckMode |= checkMode & 32; var candidatesForArgumentError; var candidateForArgumentArityError; var candidateForTypeArgumentError; @@ -63293,7 +63520,7 @@ var ts; continue; } if (argCheckMode) { - argCheckMode = 0; + argCheckMode = checkMode & 32; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -64063,7 +64290,7 @@ var ts; var newSymbol = createSymbol(2097152, "default"); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); + newSymbol.aliasTarget = resolveSymbol(symbol); memberTable.set("default", newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } @@ -64306,13 +64533,13 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 4194304), "Containing file is missing import meta node flag."); @@ -65144,15 +65371,28 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = void 0; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4) { - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4) { + break; + } + default: + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -66587,19 +66827,28 @@ var ts; if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === 258 || node.parent.kind === 257 || node.parent.kind === 259) { + checkNodeDeferred(node); + addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); + } + function checkTypeParameterDeferred(node) { + if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) { + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); var modifiers = getVarianceModifiers(typeParameter); - if (modifiers === 32768 || modifiers === 65536) { + if (modifiers) { var symbol = getSymbolOfNode(node.parent); - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperType : markerSubType); - var saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 | 32))) { + error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === 32768 || modifiers === 65536) { + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubType : markerSuperType); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperType : markerSubType); + var saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); } function checkParameter(node) { checkGrammarDecoratorsAndModifiers(node); @@ -67026,7 +67275,7 @@ var ts; superCallStatement = statement; break; } - if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -67344,8 +67593,8 @@ var ts; if (node.assertions) { var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -68514,7 +68763,7 @@ var ts; }); } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { @@ -69118,7 +69367,7 @@ var ts; } var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined); if (yieldType) { - return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; @@ -69315,7 +69564,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; @@ -70964,8 +71213,11 @@ var ts; var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration); var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!ts.isNightly()) { + grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; } @@ -71564,6 +71816,9 @@ var ts; case 226: checkClassExpressionDeferred(node); break; + case 163: + checkTypeParameterDeferred(node); + break; case 279: checkJsxSelfClosingElementDeferred(node); break; @@ -71945,7 +72200,7 @@ var ts; var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - var result = resolveEntityName(name, meaning, false, !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + var result = resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name)); if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { @@ -72037,15 +72292,14 @@ var ts; return propertyDeclaration; } } - else if (ts.isMetaProperty(parent)) { - var parentType = getTypeOfNode(parent); - var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === 103) { + else if (ts.isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === 103 && ts.idText(node) === "target") { return checkNewTargetMetaProperty(parent).symbol; } + if (parent.keywordToken === 100 && ts.idText(node) === "meta") { + return getGlobalImportMetaExpressionType().members.get("meta"); + } + return undefined; } } switch (node.kind) { @@ -72168,7 +72422,7 @@ var ts; } if (ts.isDeclaration(node)) { var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { var symbol = getSymbolAtLocation(node); @@ -72274,11 +72528,11 @@ var ts; var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] - : ts.singleElementArray(tryGetAliasTarget(symbol)); + : ts.singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol) { + function tryGetTarget(symbol) { var target; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -72463,7 +72717,7 @@ var ts; if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } - var target = getSymbolLinks(symbol).target; + var target = getSymbolLinks(symbol).aliasTarget; if (target && ts.getEffectiveModifierFlags(node) & 1 && target.flags & 111551 && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { @@ -72499,11 +72753,6 @@ var ts; !parameter.initializer && ts.hasSyntacticModifier(parameter, 16476); } - function isOptionalUninitializedParameter(parameter) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; - } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); if (!declaration) { @@ -73368,8 +73617,7 @@ var ts; case 144: var inOutFlag = modifier.kind === 101 ? 32768 : 65536; var inOutText = modifier.kind === 101 ? "in" : "out"; - if (node.kind !== 163 || (node.parent.kind !== 258 && - node.parent.kind !== 257 && node.parent.kind !== 259)) { + if (node.kind !== 163 || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { @@ -73634,6 +73882,9 @@ var ts; return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { + if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } function checkGrammarClassDeclarationHeritageClauses(node) { @@ -73858,8 +74109,22 @@ var ts; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4) { + break; + } + default: + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -74491,17 +74756,17 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } var nodeArguments = node.arguments; if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) { checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { var assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } if (nodeArguments.length === 0 || nodeArguments.length > 2) { @@ -75705,7 +75970,7 @@ var ts; value >= 52 && value < 62 ? 48 + value - 52 : value === 62 ? 43 : value === 63 ? 47 : - ts.Debug.fail(value + ": not a base64 value"); + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { return ch >= 65 && ch <= 90 ? ch - 65 : @@ -75778,7 +76043,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -77565,19 +77830,19 @@ var ts; } var statements = []; resumeLexicalEnvironment(); - var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, false, visitor); - var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + var prologueStatementCount = factory.copyPrologue(body.statements, statements, false, visitor); + var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); if (superStatementIndex >= 0) { - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); } var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment); if (superStatementIndex >= 0) { ts.addRange(statements, parameterPropertyAssignments); } else { - statements = ts.addRange(parameterPropertyAssignments, statements); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true); ts.setTextRange(block, body); @@ -78227,7 +78492,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -78997,7 +79262,7 @@ var ts; } resumeLexicalEnvironment(); var needsSyntheticConstructor = !constructor && isDerivedClass; - var indexOfFirstStatementAfterSuper = 0; + var indexOfFirstStatementAfterSuperAndPrologue = 0; var prologueStatementCount = 0; var superStatementIndex = -1; var statements = []; @@ -79005,8 +79270,11 @@ var ts; prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, false, visitor); superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount); if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; } } if (needsSyntheticConstructor) { @@ -79025,19 +79293,17 @@ var ts; } } if (parameterPropertyDeclarationCount > 0) { - var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); if (superStatementIndex >= 0) { ts.addRange(statements, parameterProperties); } - else if (needsSyntheticConstructor) { - statements = __spreadArray(__spreadArray([ - statements[0] - ], parameterProperties, true), statements.slice(1), true); - } else { - statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true); + var superAndPrologueStatementCount = prologueStatementCount; + if (needsSyntheticConstructor) + superAndPrologueStatementCount++; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true); } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -79045,7 +79311,7 @@ var ts; addMethodStatements(statements, privateMethodsAndAccessors, receiver); addPropertyOrClassStaticBlockStatements(statements, properties, receiver); if (constructor) { - ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); @@ -79477,8 +79743,8 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16); + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16); if (resolver.getNodeCheckFlags(node) & 524288) { addBlockScopedVariable(identifier); } @@ -81136,7 +81402,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 | 32 | 64); + var generatedName = factory.createUniqueName("_".concat(name), 16 | 32 | 64); var specifier = factory.createImportSpecifier(false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -82077,11 +82343,11 @@ var ts; } else { if (node.kind === 246) { - labelMarker = "break-" + label.escapedText; + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker); } } @@ -82265,7 +82531,7 @@ var ts; else { insertCaptureThisForNodeIfNeeded(prologue, constructor); } - var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), constructor.body.statements), true); + var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), constructor.body.statements), true); ts.setTextRange(body, constructor.body); return body; } @@ -87736,7 +88002,7 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (node.kind === 254 || node.kind === 203) { @@ -87933,7 +88199,7 @@ var ts; ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); } } function getTypeParameterConstraintVisibilityError() { @@ -88599,29 +88865,39 @@ var ts; } function transformImportDeclaration(decl) { if (!decl.importClause) { - return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { - return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } if (decl.importClause.namedBindings.kind === 268) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { - return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } if (resolver.isImportRequiredByAugmentation(decl)) { - return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } } + function getResolutionModeOverrideForClauseInNightly(assertClause) { + var mode = ts.getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!ts.isNightly()) { + context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } function transformAndReplaceLatePaintedStatements(statements) { while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -88786,7 +89062,7 @@ var ts; return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { @@ -88847,6 +89123,8 @@ var ts; var varDecl = factory.createVariableDeclaration(newId, undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); errorFallbackNode = undefined; var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135)] : [], factory.createVariableDeclarationList([varDecl], 2)); + preserveJsDoc(statement, input); + ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -88863,6 +89141,10 @@ var ts; return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { + if (lateMarkedStatements) { + while (ts.orderedRemoveItem(lateMarkedStatements, input)) + ; + } if (shouldStripInternal(input)) return; switch (input.kind) { @@ -89030,7 +89312,7 @@ var ts; var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104) { var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, @@ -89067,7 +89349,7 @@ var ts; })))); } } - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -89268,7 +89550,7 @@ var ts; return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return ts.transformNodeModule; default: @@ -89829,20 +90111,20 @@ var ts; addOutput(buildInfoPath); } function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) { - if (ts.fileExtensionIs(inputFileName, ".d.ts")) + if (ts.isDeclarationFileName(inputFileName)) return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json")) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -89867,7 +90149,7 @@ var ts; ts.getCommonSourceDirectory = getCommonSourceDirectory; function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts"); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; function getAllProjectOutputs(configFile, ignoreCase) { @@ -89902,12 +90184,12 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; - if (ts.fileExtensionIs(inputFileName, ".d.ts")) + if (ts.isDeclarationFileName(inputFileName)) continue; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) @@ -89921,7 +90203,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { @@ -90120,6 +90402,7 @@ var ts; else { printer.writeFile(sourceFile, writer, sourceMapGenerator); } + var sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -90131,7 +90414,8 @@ var ts; if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + sourceMapUrlPos = writer.getTextPos(); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); } if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); @@ -90141,7 +90425,7 @@ var ts; else { writer.writeLine(); } - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { @@ -90171,7 +90455,7 @@ var ts; if (mapOptions.inlineSourceMap) { var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -90335,7 +90619,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -90625,7 +90909,7 @@ var ts; setWriter(undefined, undefined); } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); + return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile))); } function emit(node, parenthesizerRule) { if (node === undefined) @@ -91148,7 +91432,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -91288,14 +91572,14 @@ var ts; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); + nonEscapingWrite("${".concat(snippet.order, ":")); pipelineEmitWithHintWorker(hint, node, false); nonEscapingWrite("}"); } function emitTabStop(hint, node, snippet) { - ts.Debug.assert(node.kind === 236, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.assert(node.kind === 236, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); ts.Debug.assert(hint !== 5, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + nonEscapingWrite("$".concat(snippet.order)); } function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; @@ -91709,7 +91993,7 @@ var ts; increaseIndent(); } var preferNewLine = node.multiLine ? 65536 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0; emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -92036,7 +92320,7 @@ var ts; } function emitExpressionStatement(node) { emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); - if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } @@ -92315,7 +92599,7 @@ var ts; if (body.multiLine) { return false; } - if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { + if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } if (getLeadingLineTerminatorCount(body, body.statements, 2) @@ -92340,12 +92624,7 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(19, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); @@ -92729,7 +93008,8 @@ var ts; } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { var emitAsSingleStatement = statements.length === 1 && - (ts.nodeIsSynthesized(parentNode) || + (!currentSourceFile || + ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969; @@ -92941,14 +93221,12 @@ var ts; function emitSourceFile(node) { writeLine(); var statements = node.statements; - if (emitBodyWithDetachedComments) { - var shouldEmitDetachedComment = statements.length === 0 || - !ts.isPrologueDirective(statements[0]) || - ts.nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -92978,17 +93256,17 @@ var ts; writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -92996,7 +93274,7 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); @@ -93005,9 +93283,9 @@ var ts; var directive = types_24[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" : "type-require", data: directive.fileName }); writeLine(); @@ -93015,7 +93293,7 @@ var ts; for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName }); writeLine(); @@ -93326,7 +93604,7 @@ var ts; onBeforeEmitNodeArray(children); } if (isEmpty) { - if (format & 1 && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 && !(format & 524288)) { @@ -93557,7 +93835,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { return 0; @@ -93565,7 +93843,7 @@ var ts; if (firstChild_1.kind === 11) { return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { @@ -93588,7 +93866,7 @@ var ts; if (nextNode.kind === 11) { return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); } @@ -93613,9 +93891,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -93672,7 +93950,7 @@ var ts; if (ts.getStartsOnNewLine(node2)) { return 1; } - if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); } @@ -93682,7 +93960,7 @@ var ts; } function isEmptyBlock(block) { return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { while (node.kind === 212 && ts.nodeIsSynthesized(node)) { @@ -93694,25 +93972,32 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return generateName(node); } - else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { - return ts.idText(node); - } - else if (node.kind === 10 && node.textSourceNode) { + if (ts.isStringLiteral(node) && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + var sourceFile = currentSourceFile; + var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node); + if (ts.isMemberName(node)) { + if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) { + return ts.idText(node); + } + } + else { + ts.Debug.assertNode(node, ts.isLiteralExpression); + if (!canUseSourceFile) { + return node.text; + } } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { if (node.kind === 10 && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); @@ -94115,8 +94400,8 @@ var ts; } function formatSynthesizedComment(comment) { return comment.kind === 3 - ? "/*" + comment.text + "*/" - : "//" + comment.text; + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); @@ -94194,7 +94479,7 @@ var ts; return true; } function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); @@ -94220,7 +94505,7 @@ var ts; forEachTrailingCommentToEmit(pos, emitTrailingComment); } function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!writer.isAtStartOfLine()) { writer.writeSpace(" "); @@ -94241,6 +94526,8 @@ var ts; exitComment(); } function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) { + if (!currentSourceFile) + return; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -94249,6 +94536,8 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!currentSourceFile) + return; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -94278,6 +94567,8 @@ var ts; return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { + if (!currentSourceFile) + return; var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); @@ -94288,7 +94579,7 @@ var ts; ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -94299,14 +94590,14 @@ var ts; } } function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } function getParsedSourceMap(node) { if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { @@ -94744,25 +95035,25 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; if (fileOrDirectoryPath === watchedDirPath) return false; if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) return false; if (ts.outFile(options) || options.outDir) return false; - if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts")) { + if (ts.isDeclarationFileName(fileOrDirectoryPath)) { if (options.declarationDir) return false; } @@ -94774,7 +95065,7 @@ var ts; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; if (hasSourceFile((filePathWithoutExtension + ".ts")) || hasSourceFile((filePathWithoutExtension + ".tsx"))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -94842,36 +95133,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -94881,16 +95172,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -95113,7 +95404,11 @@ var ts; return newValue; }; if (originalWriteFile) { - host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) { + host.writeFile = function (fileName, data) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); @@ -95127,7 +95422,7 @@ var ts; sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } if (originalDirectoryExists && originalCreateDirectory) { @@ -95180,12 +95475,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -95263,9 +95558,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -95279,7 +95574,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -95340,7 +95635,7 @@ var ts; var result = void 0; var mode = getModeForFileReference(name, containingFileMode); var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -95435,7 +95730,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -95578,7 +95873,7 @@ var ts; ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { - case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: return ts.fileExtensionIsOneOf(fileName, [".d.mts", ".mts", ".mjs"]) ? ts.ModuleKind.ESNext : ts.fileExtensionIsOneOf(fileName, [".d.cts", ".cts", ".cjs"]) ? ts.ModuleKind.CommonJS : @@ -95629,7 +95924,6 @@ var ts; ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -95820,7 +96114,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json")) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -95949,6 +96243,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, + writeFile: writeFile, }; onProgramCreateComplete(); fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { @@ -95967,6 +96262,34 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; + function addResolutionDiagnostics(list) { + if (!list) + return; + for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { + var elem = list_3[_i]; + programDiagnostics.add(elem); + } + } + function pullDiagnosticsFromCache(names, containingFile) { + var _a; + if (!moduleResolutionCache) + return; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + var containingDir = ts.getDirectoryPath(containingFileName); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var n = names_4[_i]; + var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + var name = typeof n === "string" ? n : n.fileName; + i++; + if (ts.isExternalModuleNameRelative(name)) + continue; + var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; @@ -95978,6 +96301,7 @@ var ts; ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -95996,7 +96320,7 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts", ".d.cts", ".d.mts"])) + if (redirect || !ts.isDeclarationFileName(file.originalFileName)) return redirect; var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.path); if (resultFromDts) @@ -96352,7 +96676,7 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, getSymlinkCache: getSymlinkCache, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + writeFile: writeFileCallback || writeFile, isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { @@ -96370,6 +96694,9 @@ var ts; getFileIncludeReasons: program.getFileIncludeReasons, }; } + function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true); @@ -97185,7 +97512,7 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json")) { return undefined; } return getResolvedProjectReferenceToRedirect(fileName); @@ -97227,7 +97554,7 @@ var ts; else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json")) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -97263,8 +97590,8 @@ var ts; var fileName = ts.toFileNameLowerCase(ref.fileName); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); var mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { - programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { + programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, }); } @@ -97319,7 +97646,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -97597,7 +97924,7 @@ var ts; } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && - ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -97976,7 +98303,7 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts")) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { var filePathWithoutExtension = ts.removeFileExtension(filePath); return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) || !!getSourceFileByPath((filePathWithoutExtension + ".tsx")); @@ -98073,10 +98400,10 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -98124,7 +98451,7 @@ var ts; var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath)); if (isFile && result) { var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -98268,13 +98595,9 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - var manyToManyPathMapCount = 0; function createManyToManyPathMap() { function create(forward, reverse, deleted) { - var version = 0; var map = { - id: manyToManyPathMapCount++, - version: function () { return version; }, clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, @@ -98290,30 +98613,29 @@ var ts; } set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); forward.delete(k); - version++; return true; }, set: function (k, vSet) { - var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + deleted === null || deleted === void 0 ? void 0 : deleted.delete(k); var existingVSet = forward.get(k); forward.set(k, vSet); existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(function (v) { if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } return map; }, + clear: function () { + forward.clear(); + reverse.clear(); + deleted === null || deleted === void 0 ? void 0 : deleted.clear(); + } }; return map; } @@ -98328,11 +98650,10 @@ var ts; } set.add(v); } - function deleteFromMultimap(map, k, v, removeEmpty) { - if (removeEmpty === void 0) { removeEmpty = true; } + function deleteFromMultimap(map, k, v) { var set = map.get(k); if (set === null || set === void 0 ? void 0 : set.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -98508,7 +98829,7 @@ var ts; var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts", ".d.mts", ".d.cts"]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -98553,22 +98874,11 @@ var ts; } } } + BuilderState.updateExportedModules = updateExportedModules; function updateExportedFilesMapFromCache(state, exportedModulesMapCache) { var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - var cacheId = exportedModulesMapCache.id; - var cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } @@ -98821,7 +99131,8 @@ var ts; function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) { ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath)); } - function getNextAffectedFile(state, cancellationToken, computeHash) { + function getNextAffectedFile(state, cancellationToken, computeHash, host) { + var _a; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -98831,7 +99142,7 @@ var ts; var affectedFile = affectedFiles[affectedFilesIndex]; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -98841,6 +99152,7 @@ var ts; ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); state.currentAffectedFilesSignatures.clear(); ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); state.affectedFiles = undefined; } var nextKey = state.changedFilesSet.keys().next(); @@ -98865,6 +99177,11 @@ var ts; state.seenAffectedFiles = new ts.Set(); } } + function clearAffectedFilesPendingEmit(state) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } function getNextAffectedFilePendingEmit(state) { var affectedFilesPendingEmit = state.affectedFilesPendingEmit; if (affectedFilesPendingEmit) { @@ -98880,43 +99197,42 @@ var ts; } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + function removeDiagnosticsOfLibraryFiles(state) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var program_1 = ts.Debug.checkDefined(state.program); + var options_2 = program_1.getCompilerOptions(); + ts.forEach(program_1.getSourceFiles(), function (f) { + return program_1.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2, program_1) && + removeSemanticDiagnosticsOf(state, f.resolvedPath); + }); + } + } + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.checkDefined(state.program); - var options_2 = program_1.getCompilerOptions(); - ts.forEach(program_1.getSourceFiles(), function (f) { - return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2, program_1) && - removeSemanticDiagnosticsOf(state, f.resolvedPath); - }); - } + removeDiagnosticsOfLibraryFiles(state); ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } - else { - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); - } - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); - } + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) + return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); var sourceFile = program.getSourceFileByPath(path); if (sourceFile) { - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, true); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); if (ts.getEmitDeclarations(state.compilerOptions)) { addToAffectedFilesPendingEmit(state, path, 0); } @@ -98936,11 +99252,32 @@ var ts; var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - var _a, _b; - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { + function forEachKeyOfExportedModulesMap(state, filePath, fn) { + var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); + var result = keys && ts.forEachKey(keys, fn); + if (result) + return result; + keys = state.exportedModulesMap.getKeys(filePath); + return keys && ts.forEachKey(keys, function (exportedFromPath) { + var _a; + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? + fn(exportedFromPath) : + undefined; + }); + } + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + var _a; + if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) + return false; + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined) + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + removeDiagnosticsOfLibraryFiles(state); + return true; + } + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; - } if (!isChangedSignature(state, affectedFile.resolvedPath)) return; if (state.compilerOptions.isolatedModules) { @@ -98951,7 +99288,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -98961,42 +99300,31 @@ var ts; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = new ts.Set(); - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + return true; + var references = state.referencedMap.getKeys(exportedFromPath); + return references && ts.forEachKey(references, function (filePath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + }); }); } - function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { var _a; - (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { - return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); - }); - } - function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { - var _a, _b, _c; - if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - fn(state, filePath); + if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) + return undefined; + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); }); - (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && - fn(state, referencingFilePath); + handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host); }); + return undefined; } function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { @@ -99061,8 +99389,8 @@ var ts; var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : value.version : actualSignature !== undefined ? signature === undefined ? @@ -99295,7 +99623,7 @@ var ts; return ts.emitSkippedWithNoDiagnostics; } function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); var emitKind = 1; var isPendingEmitFile = false; if (!affected) { @@ -99318,58 +99646,90 @@ var ts; affected = program; } } - return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile); + return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile); + } + function getWriteFileUpdatingSignatureCallback(writeFile) { + return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + var _a; + if (ts.isDeclarationFileName(fileName)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; + if (signature === file.version) { + var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { + if (host.storeFilesChangingSignatureDuringEmit) + (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); + if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { + state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) + ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) + writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else + state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; } function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var restorePendingEmitOnHandlingNoEmitSuccess = false; - var savedAffectedFilesPendingEmit; - var savedAffectedFilesPendingEmitKind; - var savedAffectedFilesPendingEmitIndex; - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !ts.outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } + var _a; if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - var sourceMaps = []; - var emitSkipped = false; - var diagnostics = void 0; - var emittedFiles = []; - var affectedEmitResult = void 0; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + var sourceMaps = []; + var emitSkipped = false; + var diagnostics = void 0; + var emittedFiles = []; + var affectedEmitResult = void 0; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped: emitSkipped, + diagnostics: diagnostics || ts.emptyArray, + emittedFiles: emittedFiles, + sourceMaps: sourceMaps + }; + } + else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) { + ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + if (!emitOnlyDtsFiles + || ts.every(state.affectedFilesPendingEmit, function (path, index) { + return index < state.affectedFilesPendingEmitIndex || + state.affectedFilesPendingEmitKind.get(path) === 0; + })) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped: emitSkipped, - diagnostics: diagnostics || ts.emptyArray, - emittedFiles: emittedFiles, - sourceMaps: sourceMaps - }; } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { return undefined; } @@ -99744,8 +100104,8 @@ var ts; !!redirectedReference; var seenNamesInFile = ts.createModeAwareCache(); var i = 0; - for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { - var entry = names_4[_i]; + for (var _i = 0, names_5 = names; _i < names_5.length; _i++) { + var entry = names_5[_i]; var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase(); var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) : containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined; @@ -99879,7 +100239,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { return { dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator), @@ -100237,7 +100597,7 @@ var ts; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { var _a; - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { return false; } @@ -100271,14 +100631,14 @@ var ts; if (options === void 0) { options = {}; } var info = getInfo(importingSourceFile.path, host); var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, true, options.overrideImportMode); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, true, options.overrideImportMode); }); } moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) { if (options === void 0) { options = {}; } var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode); }) || + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { @@ -100344,7 +100704,7 @@ var ts; var relativeSpecifiers; for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { var modulePath = modulePaths_1[_i]; - var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode); + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { return nodeModulesSpecifiers; @@ -100675,7 +101035,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) { + function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) { var path = _a.path, isRedirect = _a.isRedirect; var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { @@ -100688,8 +101048,9 @@ var ts; var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; - var moduleFileNameForExtensionless = void 0; + var moduleFileName = void 0; while (true) { var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) { @@ -100705,11 +101066,11 @@ var ts; isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) - moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) + moduleFileName = moduleFileToTry; packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -100733,7 +101094,7 @@ var ts; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); - if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) @@ -100758,7 +101119,7 @@ var ts; moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } - var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -100766,14 +101127,13 @@ var ts; } } } - return { moduleFileToTry: moduleFileToTry }; - } - function getExtensionlessFileName(path) { - var fullModulePathWithoutExtension = ts.removeFileExtension(path); - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath }; + } } - return fullModulePathWithoutExtension; + return { moduleFileToTry: moduleFileToTry }; } } function tryGetAnyFileFromPath(host, path) { @@ -100794,7 +101154,7 @@ var ts; return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } - function removeExtensionAndIndexPostFix(fileName, ending, options) { + function removeExtensionAndIndexPostFix(fileName, ending, options, host) { if (ts.fileExtensionIsOneOf(fileName, [".json", ".mjs", ".cjs"])) return fileName; var noExtension = ts.removeFileExtension(fileName); @@ -100802,7 +101162,11 @@ var ts; return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { case 0: - return ts.removeSuffix(noExtension, "/index"); + var withoutIndex = ts.removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + return noExtension; + } + return withoutIndex; case 1: return noExtension; case 2: @@ -100813,7 +101177,7 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); @@ -100903,8 +101267,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -100912,8 +101276,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -100935,7 +101299,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -100968,7 +101332,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -100981,7 +101345,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -101004,7 +101368,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -101031,9 +101395,9 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; @@ -101071,7 +101435,7 @@ var ts; if (isJsonFile && !ts.endsWith(includeSpec, ".json")) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -101080,7 +101444,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -101191,7 +101555,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -101288,6 +101652,7 @@ var ts; createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -101341,6 +101706,7 @@ var ts; createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } ts.createProgramHost = createProgramHost; @@ -101417,6 +101783,7 @@ var ts; var host = ts.createCompilerHostWorker(options, undefined, system); host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -101498,7 +101865,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -101645,10 +102012,10 @@ var ts; } function createNewProgram(hasInvalidatedResolution) { writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -101790,7 +102157,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -101846,7 +102213,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -101884,7 +102251,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -102124,9 +102491,6 @@ var ts; function newer(date1, date2) { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts"); - } function isCircularBuildOrder(buildOrder) { return !!buildOrder && !!buildOrder.buildOrder; } @@ -102137,8 +102501,8 @@ var ts; ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -102664,7 +103028,7 @@ var ts; outputFiles.forEach(function (_a) { var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; var priorChangeTime; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && ts.isDeclarationFileName(name)) { if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); } @@ -102881,7 +103245,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -102910,7 +103274,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -102936,7 +103300,7 @@ var ts; if (!host.fileExists(inputFile)) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (!force) { @@ -102980,7 +103344,7 @@ var ts; newestOutputFileTime = outputTime; newestOutputFileName = output; } - if (isDeclarationFile(output)) { + if (ts.isDeclarationFileName(output)) { var outputModifiedTime = ts.getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -103120,7 +103484,7 @@ var ts; reportVerbose = false; reportStatus(state, verboseMessage, proj.options.configFilePath); } - if (isDeclarationFile(file)) { + if (ts.isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); @@ -103261,7 +103625,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -103362,7 +103726,7 @@ var ts; if (!state.watch || !state.lastCachedPackageJsonLookups) return; ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { - createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, onDeleteValue: ts.closeFileWatcher, }); } @@ -103611,7 +103975,7 @@ var ts; }; } function bold(str) { - return "\u001B[1m" + str + "\u001B[22m"; + return "\u001B[1m".concat(str, "\u001B[22m"); } var isWindows = sys.getEnvironmentVariable("OS") && ts.stringContains(sys.getEnvironmentVariable("OS").toLowerCase(), "windows"); var isWindowsTerminal = sys.getEnvironmentVariable("WT_SESSION"); @@ -103620,19 +103984,19 @@ var ts; if (isWindows && !isWindowsTerminal && !isVSCode) { return brightWhite(str); } - return "\u001B[94m" + str + "\u001B[39m"; + return "\u001B[94m".concat(str, "\u001B[39m"); } var supportsRicherColors = sys.getEnvironmentVariable("COLORTERM") === "truecolor" || sys.getEnvironmentVariable("TERM") === "xterm-256color"; function blueBackground(str) { if (supportsRicherColors) { - return "\u001B[48;5;68m" + str + "\u001B[39;49m"; + return "\u001B[48;5;68m".concat(str, "\u001B[39;49m"); } else { - return "\u001B[44m" + str + "\u001B[39;49m"; + return "\u001B[44m".concat(str, "\u001B[39;49m"); } } function brightWhite(str) { - return "\u001B[97m" + str + "\u001B[39m"; + return "\u001B[97m".concat(str, "\u001B[39m"); } return { bold: bold, @@ -103642,7 +104006,7 @@ var ts; }; } function getDisplayNameTextOfOption(option) { - return "--" + option.name + (option.shortName ? ", -" + option.shortName : ""); + return "--".concat(option.name).concat(option.shortName ? ", -".concat(option.shortName) : ""); } function generateOptionOutput(sys, option, rightAlignOfLeft, leftAlignOfRight) { var _a, _b; @@ -103679,13 +104043,13 @@ var ts; text.push(sys.newLine); if (showAdditionalInfoOutput(valueCandidates, option)) { if (valueCandidates) { - text.push(valueCandidates.valueType + " " + valueCandidates.possibleValues); + text.push("".concat(valueCandidates.valueType, " ").concat(valueCandidates.possibleValues)); } if (defaultValueDescription) { if (valueCandidates) text.push(sys.newLine); var diagType = ts.getDiagnosticText(ts.Diagnostics.default_Colon); - text.push(diagType + " " + defaultValueDescription); + text.push("".concat(diagType, " ").concat(defaultValueDescription)); } text.push(sys.newLine); } @@ -103734,7 +104098,7 @@ var ts; } var curRight = remainRight.substr(0, rightCharacterNumber); remainRight = remainRight.slice(rightCharacterNumber); - res.push("" + curLeft + curRight); + res.push("".concat(curLeft).concat(curRight)); isFirstLine = false; } return res; @@ -103835,7 +104199,7 @@ var ts; categoryMap.set(curCategory, optionsOfCurCategory); } categoryMap.forEach(function (value, key) { - res.push("### " + key + sys.newLine + sys.newLine); + res.push("### ".concat(key).concat(sys.newLine).concat(sys.newLine)); res = __spreadArray(__spreadArray([], res, true), generateGroupOptionOutput(sys, value), true); }); if (afterOptionsDescription) { @@ -103845,7 +104209,7 @@ var ts; } function printEasyHelp(sys, simpleOptions) { var colors = createColors(sys); - var output = __spreadArray([], getHeader(sys, ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler) + " - " + ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version)), true); + var output = __spreadArray([], getHeader(sys, "".concat(ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler), " - ").concat(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version))), true); output.push(colors.bold(ts.getDiagnosticText(ts.Diagnostics.COMMON_COMMANDS)) + sys.newLine + sys.newLine); example("tsc", ts.Diagnostics.Compiles_the_current_project_tsconfig_json_in_the_working_directory); example("tsc app.ts util.ts", ts.Diagnostics.Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options); @@ -103871,7 +104235,7 @@ var ts; } } function printAllHelp(sys, compilerOptions, buildOptions, watchOptions) { - var output = __spreadArray([], getHeader(sys, ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler) + " - " + ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version)), true); + var output = __spreadArray([], getHeader(sys, "".concat(ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler), " - ").concat(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version))), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.ALL_COMPILER_OPTIONS), compilerOptions, true, undefined, ts.formatMessage(undefined, ts.Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc")), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.WATCH_OPTIONS), watchOptions, false, ts.getDiagnosticText(ts.Diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon)), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.BUILD_OPTIONS), buildOptions, false, ts.formatMessage(undefined, ts.Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")), true); @@ -103881,7 +104245,7 @@ var ts; } } function printBuildHelp(sys, buildOptions) { - var output = __spreadArray([], getHeader(sys, ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler) + " - " + ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version)), true); + var output = __spreadArray([], getHeader(sys, "".concat(ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler), " - ").concat(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version))), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.BUILD_OPTIONS), buildOptions, false, ts.formatMessage(undefined, ts.Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")), true); for (var _i = 0, output_3 = output; _i < output_3.length; _i++) { var line = output_3[_i]; @@ -104262,7 +104626,7 @@ var ts; reportCountStatistic("Subtype cache size", caches.subtype); reportCountStatistic("Strict subtype cache size", caches.strictSubtype); if (isPerformanceEnabled) { - ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); }); + ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic("".concat(name, " time"), duration); }); } } else if (isPerformanceEnabled) { @@ -104333,7 +104697,7 @@ var ts; // This file actually uses arguments passed on commandline and executes it ts.Debug.loggingHost = { log: function (_level, s) { - ts.sys.write("" + (s || "") + ts.sys.newLine); + ts.sys.write("".concat(s || "").concat(ts.sys.newLine)); } }; if (ts.Debug.isDebugging) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 15f392c388d78..24ce7cbf34df2 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -100,7 +100,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "".concat(ts.versionMajorMinor, ".1-rc"); /* @internal */ var Comparison; (function (Comparison) { @@ -147,7 +147,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -839,9 +839,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -877,7 +877,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -931,27 +931,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1191,12 +1191,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1650,7 +1650,7 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ @@ -1741,7 +1741,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -1813,11 +1813,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -1835,7 +1835,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -1852,14 +1852,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -1890,13 +1890,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -1926,7 +1926,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -1987,9 +1987,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2108,24 +2108,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2135,7 +2135,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2191,7 +2191,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2291,12 +2291,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2427,7 +2427,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2506,7 +2506,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2514,12 +2514,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2529,26 +2529,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2579,42 +2579,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2635,7 +2635,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2656,7 +2656,7 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "" + result + (result ? "|" : "") + enumName; + result = "".concat(result).concat(result ? "|" : "").concat(enumName); remainingFlags &= ~enumValue; } } @@ -2753,20 +2753,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2805,7 +2805,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -2857,10 +2857,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -2869,35 +2869,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -2929,11 +2929,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -2965,7 +2965,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3012,10 +3012,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3129,9 +3129,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3146,11 +3146,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3179,11 +3179,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3200,7 +3200,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3417,7 +3417,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3715,7 +3715,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3727,11 +3727,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -3821,20 +3821,20 @@ var ts; } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -3870,7 +3870,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -3879,7 +3879,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -3887,7 +3887,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -3896,7 +3896,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -3906,7 +3906,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -3914,7 +3914,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -3923,7 +3923,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -3941,7 +3941,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4660,7 +4660,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; - NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -5277,10 +5276,11 @@ var ts; ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16"; ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var ModuleDetectionKind; @@ -5290,7 +5290,7 @@ var ts; */ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy"; /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto"; /** @@ -5335,8 +5335,8 @@ var ts; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + ModuleKind[ModuleKind["Node16"] = 100] = "Node16"; ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); var JsxEmit; @@ -5872,37 +5872,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -5974,7 +5974,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6191,7 +6191,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6443,7 +6443,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6456,7 +6456,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6472,7 +6472,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6495,7 +6495,7 @@ var ts; var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6590,7 +6590,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6645,7 +6645,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6677,7 +6677,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6932,7 +6932,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -6941,7 +6941,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -6957,7 +6957,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7059,7 +7059,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -7084,7 +7084,7 @@ var ts; } } if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -7100,7 +7100,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7251,8 +7251,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7264,10 +7264,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7331,8 +7331,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7355,7 +7355,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7442,16 +7442,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7465,18 +7465,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7496,7 +7496,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7573,7 +7573,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -7857,17 +7857,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -7884,7 +7884,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8258,6 +8258,7 @@ var ts; _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), @@ -8269,10 +8270,10 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), - Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -8287,7 +8288,7 @@ var ts; 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_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_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -8318,7 +8319,7 @@ var ts; await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -8370,7 +8371,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), - Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), @@ -8388,7 +8389,7 @@ var ts; Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), - Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."), + Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."), resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), @@ -8399,7 +8400,7 @@ var ts; An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), - auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8408,7 +8409,8 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), - This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -8659,7 +8661,6 @@ var ts; A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), - 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."), Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), 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."), @@ -8717,6 +8718,7 @@ var ts; _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8872,6 +8874,7 @@ var ts; This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), @@ -8885,8 +8888,8 @@ var ts; Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), @@ -8997,6 +9000,7 @@ var ts; This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -9552,7 +9556,6 @@ var ts; This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), - JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -9862,100 +9865,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10044,16 +10047,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10082,17 +10085,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10117,7 +10120,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10195,18 +10198,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10220,50 +10223,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10277,29 +10280,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10310,10 +10313,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10323,24 +10326,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10348,7 +10351,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10372,8 +10375,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10384,18 +10387,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10456,12 +10459,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10471,20 +10474,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10495,7 +10498,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10520,7 +10523,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10575,17 +10578,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10604,7 +10607,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10627,15 +10630,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10690,8 +10693,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10715,7 +10718,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10725,15 +10728,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10746,7 +10749,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10758,10 +10761,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -10819,8 +10822,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10835,11 +10838,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -10849,7 +10852,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -10863,7 +10866,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10873,7 +10876,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -10881,7 +10884,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10894,7 +10897,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -10902,28 +10905,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -10931,10 +10934,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -10957,47 +10960,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11005,29 +11008,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11035,14 +11038,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11075,7 +11078,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11091,7 +11094,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11101,7 +11104,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11119,11 +11122,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11132,7 +11135,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11151,14 +11154,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11169,8 +11172,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11185,101 +11188,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11288,98 +11291,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11392,20 +11395,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11413,7 +11416,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11425,18 +11428,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11444,10 +11447,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11455,10 +11458,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11466,175 +11469,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11644,7 +11647,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11655,23 +11658,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11685,41 +11688,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11727,13 +11730,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11742,19 +11745,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11764,7 +11767,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11785,9 +11788,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11795,7 +11798,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -11809,42 +11812,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -11852,20 +11855,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -11888,7 +11891,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -11901,16 +11904,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11931,10 +11934,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -11946,86 +11949,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12100,9 +12103,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12168,23 +12171,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12392,9 +12395,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12402,7 +12405,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12432,14 +12435,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12553,7 +12556,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12571,7 +12574,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12582,7 +12585,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12612,30 +12615,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12670,42 +12673,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12998,16 +13001,16 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a @@ -13018,7 +13021,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13045,33 +13048,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13106,7 +13109,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13115,25 +13118,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13142,12 +13145,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13163,7 +13166,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13172,7 +13175,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13193,7 +13196,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13203,7 +13206,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13212,8 +13215,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13222,13 +13225,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13240,13 +13243,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13264,20 +13267,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13285,12 +13288,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13299,24 +13302,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13336,18 +13339,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13356,14 +13359,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13378,30 +13381,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13411,13 +13414,13 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13426,12 +13429,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13446,8 +13449,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13458,8 +13461,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13467,15 +13470,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13484,9 +13487,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13507,8 +13510,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13517,10 +13520,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13532,8 +13535,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13542,26 +13545,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13569,13 +13572,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13585,36 +13588,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13627,13 +13630,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13642,11 +13645,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13663,15 +13666,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13679,8 +13682,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13691,13 +13694,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13715,18 +13718,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13750,115 +13753,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13885,10 +13888,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -13902,76 +13905,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -13981,15 +13984,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14015,13 +14018,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14029,12 +14032,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14063,11 +14066,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion @@ -14108,7 +14111,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14269,11 +14272,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14304,28 +14307,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14336,16 +14339,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14360,7 +14363,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14413,7 +14416,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14447,7 +14450,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14479,9 +14482,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14493,13 +14496,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14508,7 +14511,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14516,10 +14519,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14530,7 +14533,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14541,7 +14544,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14702,62 +14705,62 @@ var ts; var _a; // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14772,21 +14775,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -14810,16 +14813,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -14831,9 +14834,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -14845,7 +14848,7 @@ var ts; } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isCommonJSContainingModuleKind(kind) { - return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext; } function isEffectiveExternalModule(node, compilerOptions) { return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); @@ -14857,10 +14860,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -14890,24 +14893,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -14917,9 +14920,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -14929,25 +14932,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -14957,25 +14960,29 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; } } ts.isAnyImportSyntax = isAnyImportSyntax; + function isAnyImportOrBareOrAccessedRequire(node) { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15016,19 +15023,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15043,21 +15050,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15147,7 +15154,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15161,7 +15168,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15170,29 +15177,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15224,36 +15231,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15262,12 +15269,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15286,24 +15293,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15312,48 +15319,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15362,40 +15369,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15420,23 +15427,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15446,23 +15453,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15485,10 +15492,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15498,12 +15505,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15511,14 +15518,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15530,21 +15537,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15555,13 +15562,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15572,7 +15579,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15580,30 +15587,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15665,14 +15672,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15687,9 +15694,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15700,27 +15707,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15733,17 +15740,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15767,9 +15774,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15791,28 +15798,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15828,21 +15835,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15851,8 +15858,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15860,34 +15867,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -15895,10 +15902,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15911,25 +15918,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -15945,11 +15952,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15965,9 +15972,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15975,64 +15982,64 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16042,49 +16049,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16092,10 +16099,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16103,7 +16110,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16116,7 +16123,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16128,11 +16135,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16140,7 +16147,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16148,15 +16155,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16182,7 +16189,7 @@ var ts; } ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { - if (node.kind === 203 /* BindingElement */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && @@ -16196,11 +16203,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16211,7 +16218,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16238,7 +16245,7 @@ var ts; * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16264,11 +16271,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16286,7 +16293,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16294,7 +16301,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16302,8 +16309,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16325,17 +16332,13 @@ var ts; if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - var nameOrArgument = getNameOrArgument(initializer); - if (ts.isPrivateIdentifier(nameOrArgument)) { - ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -16369,7 +16372,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16394,14 +16397,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16420,23 +16423,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16473,17 +16476,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16495,14 +16498,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16513,12 +16516,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16526,7 +16529,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16539,18 +16542,18 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { - var _a, _b, _c; + var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: - return node.initializer.arguments[0].text; - case 266 /* ImportDeclaration */: - return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: - return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + case 254 /* SyntaxKind.VariableDeclaration */: + return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; + case 266 /* SyntaxKind.ImportDeclaration */: + return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); } @@ -16562,14 +16565,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16579,17 +16582,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16597,11 +16600,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16609,7 +16612,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16630,13 +16633,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16650,7 +16653,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16660,27 +16663,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16692,7 +16695,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16707,11 +16710,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16740,13 +16743,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16757,7 +16760,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16781,7 +16784,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16847,7 +16850,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16864,41 +16867,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -16909,7 +16912,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -16918,22 +16921,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -16950,11 +16953,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16964,7 +16967,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -16973,18 +16976,18 @@ var ts; ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17005,13 +17008,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17022,13 +17025,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17037,7 +17040,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17045,27 +17048,30 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - // Any name in an export specifier or JSX Attribute + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + // Any name in an export specifier or JSX Attribute or Jsx Element return true; } return false; @@ -17081,36 +17087,44 @@ var ts; // export = // export default // module.exports = - // {} - // {name: } + // module.exports.x = + // const x = require("...") + // const { x } = require("...") + // const x = require("...").y + // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 297 /* ShorthandPropertyAssignment */ || - node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { + return true; + } + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) + && ts.isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17129,7 +17143,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17146,7 +17160,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17155,7 +17169,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17168,7 +17182,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17195,11 +17209,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17207,7 +17221,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17226,7 +17240,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17239,38 +17253,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17280,7 +17294,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17297,7 +17311,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17307,19 +17321,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17332,10 +17346,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17351,11 +17365,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17370,7 +17384,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17379,11 +17393,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17391,15 +17405,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17418,58 +17432,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17648,129 +17662,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17780,9 +17794,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -17897,9 +17911,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -17914,8 +17928,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -17945,13 +17959,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -17970,13 +17984,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -17993,6 +18007,10 @@ var ts; return indentStrings[1].length; } ts.getIndentSize = getIndentSize; + function isNightly() { + return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders"); + } + ts.isNightly = isNightly; function createTextWriter(newLine) { var output; var indent; @@ -18217,12 +18235,22 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; + /** + * This function is an inverse of `getDeclarationEmitExtensionForPath`. + */ + function getPossibleOriginalInputExtensionForExtension(path) { + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; + } + ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { return options.outFile || options.out; } @@ -18282,10 +18310,10 @@ var ts; return ts.combinePaths(newDirPath, sourceFilePath); } ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) { diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } ts.writeFile = writeFile; function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) { @@ -18348,7 +18376,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18358,11 +18386,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18373,10 +18401,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18396,10 +18424,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18448,7 +18476,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18565,7 +18593,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18640,7 +18668,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18652,11 +18680,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18673,23 +18701,23 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18701,16 +18729,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18735,22 +18763,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18770,14 +18798,14 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18789,22 +18817,22 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -18812,15 +18840,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -18828,7 +18856,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -18841,14 +18869,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -18860,8 +18888,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -18871,33 +18899,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18928,10 +18956,15 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfAccessExpression(node) { + return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { return ts.isQualifiedName(node.parent) && node.parent.right === node || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -18939,12 +18972,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -18960,7 +18993,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19131,9 +19164,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19276,8 +19309,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19301,32 +19334,32 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SyntaxKind.SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19335,11 +19368,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19354,47 +19387,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19464,9 +19497,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19477,11 +19510,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19528,44 +19561,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19573,7 +19606,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19583,31 +19616,66 @@ var ts; return expr; } ts.getLeftmostAccessExpression = getLeftmostAccessExpression; + function forEachNameInAccessChainWalkingLeft(name, action) { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + function walkAccessExpression(access) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { + if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { + var res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + // Chain interrupted by non-static-name access 'x[expr()].y.z' + return undefined; + } + } + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (ts.isIdentifier(access.expression)) { + // End of chain at Identifier 'x.y.z' + return action(access.expression); + } + // End of chain at non-Identifier 'x().y.z' + return undefined; + } + } + ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19641,9 +19709,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19652,8 +19720,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19661,8 +19729,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -19857,7 +19925,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -19866,43 +19934,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -19912,16 +19980,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -19930,7 +19998,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -19962,15 +20030,15 @@ var ts; file.externalModuleIndicator = ts.isFileProbablyExternalModule(file); }; case ts.ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } var combined_1 = ts.or.apply(void 0, checks); @@ -19981,15 +20049,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -19999,8 +20067,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -20025,7 +20093,7 @@ var ts; case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; default: @@ -20050,7 +20118,7 @@ var ts; return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; } @@ -20086,7 +20154,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20103,14 +20171,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20118,13 +20186,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20223,9 +20291,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20238,7 +20306,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20247,7 +20315,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20265,10 +20333,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20290,7 +20358,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20327,11 +20395,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20368,7 +20436,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20493,43 +20561,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20537,7 +20606,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20548,11 +20617,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20583,7 +20652,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20636,11 +20705,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20649,7 +20718,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20758,23 +20827,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20790,10 +20859,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -20828,7 +20897,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -20839,34 +20908,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21007,7 +21076,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21027,18 +21096,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return node.parent.decorators; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21046,45 +21115,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21096,7 +21165,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21114,7 +21183,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21123,7 +21192,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21162,7 +21231,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21182,42 +21251,47 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; + function getParameterTypeNode(parameter) { + var _a; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + } + ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); /* @internal */ var ts; @@ -21340,28 +21414,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21372,7 +21446,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21392,8 +21466,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21409,7 +21483,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21427,10 +21501,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21443,7 +21517,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21451,11 +21525,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21469,7 +21543,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21486,10 +21560,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21519,8 +21593,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21533,9 +21607,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21555,7 +21629,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21577,7 +21651,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21586,21 +21660,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21618,16 +21692,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21639,8 +21713,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21655,8 +21729,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21673,14 +21747,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21700,9 +21774,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21896,11 +21970,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -21958,10 +22032,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22092,12 +22166,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22253,18 +22327,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22300,30 +22374,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22391,38 +22465,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22526,11 +22600,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22548,7 +22622,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) { @@ -22559,7 +22633,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseSignatureDeclaration(updated, original) { @@ -22571,9 +22645,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseFunctionLikeDeclaration(updated, original) { @@ -22607,7 +22681,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22620,21 +22694,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22643,7 +22717,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22654,19 +22728,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22676,10 +22750,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22698,8 +22772,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22711,9 +22785,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22723,25 +22797,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22749,9 +22823,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 8388608 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22761,51 +22835,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 33554432 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 8192 /* ContainsLexicalThis */; + transformFlags = 8192 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -22818,23 +22892,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -22846,34 +22920,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -22881,7 +22955,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -22898,12 +22972,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 65536 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -22926,11 +23000,11 @@ var ts; name = modifiersOrName; constraint = nameOrConstraint; } - var node = createBaseNamedDeclaration(163 /* TypeParameter */, + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, /*decorators*/ undefined, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateTypeParameterDeclaration(node, modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { @@ -22956,22 +23030,22 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -22989,12 +23063,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + 1 /* TransformFlags.ContainsTypeScript */ | + 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; return node; } // @api @@ -23008,11 +23082,11 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23026,18 +23100,18 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + 8388608 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23055,10 +23129,10 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23074,26 +23148,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -23113,11 +23187,11 @@ var ts; } // @api function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, decorators, modifiers, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @api @@ -23130,11 +23204,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23148,7 +23222,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(172 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -23164,7 +23238,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(173 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -23180,11 +23254,11 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23197,11 +23271,11 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23214,10 +23288,10 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23231,10 +23305,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23253,11 +23327,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23270,10 +23344,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23285,11 +23359,11 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23311,10 +23385,10 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23345,10 +23419,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23360,9 +23434,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23373,9 +23447,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23386,9 +23460,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23399,12 +23473,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23418,9 +23492,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23431,9 +23505,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23445,7 +23519,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23455,7 +23529,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23463,7 +23537,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23471,12 +23545,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23490,9 +23564,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23503,10 +23577,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23517,22 +23591,22 @@ var ts; : node; } function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertion; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; @@ -23547,9 +23621,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23560,18 +23634,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23582,10 +23656,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23597,14 +23671,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23620,9 +23694,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23636,16 +23710,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23657,12 +23731,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23673,21 +23747,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 16384 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23709,7 +23783,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23728,7 +23802,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23742,7 +23816,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -23754,8 +23828,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23771,13 +23845,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -23787,7 +23861,7 @@ var ts; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -23798,7 +23872,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -23808,8 +23882,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23825,8 +23899,8 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); @@ -23834,12 +23908,12 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -23850,7 +23924,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -23859,13 +23933,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 4194304 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -23882,8 +23956,8 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); @@ -23893,18 +23967,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -23914,7 +23988,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -23922,9 +23996,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23938,7 +24012,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -23946,12 +24020,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23965,13 +24039,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23983,7 +24057,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -23996,23 +24070,23 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24030,15 +24104,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24055,7 +24129,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24068,7 +24142,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24081,7 +24155,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24094,13 +24168,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24111,17 +24185,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24133,7 +24207,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24142,7 +24216,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24154,7 +24228,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24164,46 +24238,46 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) - return 32768 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return 32768 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24211,7 +24285,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24223,11 +24297,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24249,13 +24323,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24266,8 +24340,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24293,41 +24367,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 524288 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24339,12 +24413,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24355,8 +24429,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24372,17 +24446,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24394,13 +24468,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24412,11 +24486,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24430,33 +24504,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24474,13 +24548,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24492,8 +24566,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24501,7 +24575,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24515,12 +24589,12 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24533,11 +24607,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24550,7 +24624,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24570,7 +24644,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24587,7 +24661,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24604,7 +24678,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24627,7 +24701,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24647,7 +24721,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24657,9 +24731,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24673,11 +24747,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24688,11 +24762,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24703,13 +24777,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24720,7 +24794,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24737,7 +24811,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24754,7 +24828,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24771,7 +24845,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24784,7 +24858,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -24804,17 +24878,17 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24829,17 +24903,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -24851,25 +24925,25 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } return node; @@ -24889,14 +24963,14 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -24914,9 +24988,9 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24932,9 +25006,9 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24949,12 +25023,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -24968,21 +25042,21 @@ var ts; } // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */, decorators, modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */, decorators, modifiers); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -24996,7 +25070,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25009,7 +25083,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25022,10 +25096,10 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25036,13 +25110,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -25057,14 +25131,14 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25079,7 +25153,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25087,9 +25161,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25102,10 +25176,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25117,10 +25191,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25132,7 +25206,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25146,10 +25220,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25160,12 +25234,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25176,10 +25250,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25190,14 +25264,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25210,13 +25284,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25229,7 +25303,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -25237,7 +25311,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25253,10 +25327,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25267,14 +25341,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25287,7 +25361,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */, + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -25297,10 +25371,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25355,7 +25429,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -25372,7 +25446,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25386,7 +25460,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25398,7 +25472,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25427,7 +25501,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25444,7 +25518,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25462,7 +25536,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25483,7 +25557,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25504,7 +25578,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25522,7 +25596,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25537,13 +25611,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25557,7 +25631,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25569,7 +25643,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25586,7 +25660,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25599,7 +25673,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25612,7 +25686,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25684,7 +25758,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -25696,7 +25770,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -25708,7 +25782,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -25725,7 +25799,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -25733,7 +25807,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25746,7 +25820,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25754,9 +25828,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25770,7 +25844,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25778,9 +25852,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25794,11 +25868,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25809,7 +25883,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -25817,7 +25891,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25830,10 +25904,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25845,25 +25919,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25875,11 +25949,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25890,11 +25964,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25905,13 +25979,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25925,7 +25999,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -25942,7 +26016,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -25955,16 +26029,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -25979,7 +26053,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -25992,7 +26066,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26007,7 +26081,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -26037,13 +26111,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -26069,12 +26143,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26088,13 +26162,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26109,7 +26183,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26126,7 +26200,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26165,7 +26239,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26180,7 +26254,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26198,28 +26272,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26230,7 +26304,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26238,7 +26312,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26253,7 +26327,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26267,12 +26341,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26295,7 +26369,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26312,7 +26386,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26323,14 +26397,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26352,12 +26426,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26471,11 +26545,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26501,7 +26575,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26522,20 +26596,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26543,7 +26617,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26552,11 +26626,11 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); } @@ -26623,9 +26697,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26644,7 +26718,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26657,7 +26731,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26670,7 +26744,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -26695,9 +26769,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -26714,7 +26788,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -26772,7 +26846,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -26961,52 +27035,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27015,14 +27089,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27031,22 +27105,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 33562624 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27058,78 +27132,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 589443072 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 557748224 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 591310848 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537165824 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 536940544 /* ClassExcludes */; - case 171 /* Constructor */: - return 591306752 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 570433536 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 574529536 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 536973312 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536903680 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536887296 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return 536887296 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return 589443072 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return 536870912 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return 557748224 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return 591310848 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return 537165824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return 536940544 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return 591306752 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return 570433536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return 574529536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return 536973312 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return 536903680 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return 536887296 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return 536870912 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return 536870912 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return 536870912 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27139,7 +27213,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27202,50 +27276,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27273,22 +27347,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27316,7 +27390,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27385,7 +27459,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27427,7 +27501,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27436,7 +27510,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27468,7 +27542,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -27704,7 +27778,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -27727,8 +27801,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -27769,7 +27843,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -27804,7 +27878,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -27820,7 +27894,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -27874,13 +27948,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -27893,7 +27967,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -27983,13 +28057,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28396,7 +28470,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28405,741 +28479,741 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29147,176 +29221,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29336,7 +29410,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29515,14 +29589,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29561,7 +29635,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29586,14 +29660,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29601,7 +29675,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29630,8 +29704,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29647,26 +29721,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29674,7 +29748,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -29736,7 +29810,7 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -29781,10 +29855,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -29903,7 +29977,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -29915,11 +29989,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -29951,12 +30025,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -29974,7 +30048,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -29989,7 +30063,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30004,7 +30078,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30019,21 +30093,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30054,29 +30128,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30087,68 +30161,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30156,21 +30230,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30303,7 +30377,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30384,7 +30458,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30404,9 +30478,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30418,14 +30492,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 93 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30437,7 +30511,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30453,20 +30527,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30474,9 +30548,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -30484,7 +30558,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30492,51 +30566,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.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 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30548,345 +30622,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.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 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -30895,64 +30969,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31001,7 +31075,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31026,13 +31100,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31080,7 +31154,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31108,8 +31182,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31131,7 +31205,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31229,7 +31303,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31248,25 +31322,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31274,28 +31348,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31313,7 +31387,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31322,10 +31396,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31362,15 +31436,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31402,13 +31476,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31441,7 +31515,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31469,12 +31543,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31492,7 +31566,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31512,8 +31586,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31554,7 +31628,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -31581,16 +31655,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -31631,52 +31705,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -31777,15 +31851,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -31797,7 +31871,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -31805,31 +31879,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -31867,7 +31941,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -31882,17 +31956,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -31902,7 +31976,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -31927,24 +32001,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -31955,7 +32029,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32022,24 +32096,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32056,7 +32130,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32068,11 +32142,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32096,23 +32170,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32125,23 +32199,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32154,12 +32228,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32187,23 +32261,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32211,9 +32285,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32224,18 +32298,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32244,50 +32318,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32299,42 +32373,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32343,7 +32417,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32360,8 +32434,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32376,51 +32450,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32440,7 +32514,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32448,7 +32522,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32514,7 +32588,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32537,38 +32611,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -32615,20 +32689,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -32637,8 +32711,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -32647,58 +32721,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -32719,7 +32793,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -32737,39 +32811,39 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` } } @@ -32784,11 +32858,12 @@ var ts; var startPos = scanner.getStartPos(); var result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -32798,13 +32873,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -32833,7 +32908,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -32851,18 +32926,18 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) { + function parseEntityName(allowReservedWords, diagnosticMessage) { var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; } dotPos = getNodePos(); - entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos); + entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos); } return entity; } @@ -32895,12 +32970,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -32911,7 +32986,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -32929,7 +33004,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -32937,13 +33012,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -32958,30 +33033,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -32995,11 +33070,11 @@ var ts; } // TYPES function parseEntityNameOfTypeReference() { - return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected); + return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33009,14 +33084,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33054,12 +33129,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33071,8 +33146,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33080,9 +33155,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*decorators*/ undefined, @@ -33096,15 +33171,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33113,13 +33188,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33127,9 +33202,10 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true); - var typeArguments = tryParseTypeArguments(); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); + var entityName = parseEntityName(/*allowReservedWords*/ true); + // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. + var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } function parseTypeParameter() { @@ -33138,7 +33214,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33157,21 +33233,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33195,7 +33271,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33211,7 +33287,7 @@ var ts; // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), @@ -33225,11 +33301,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33239,16 +33315,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33270,11 +33346,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33293,17 +33369,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33312,20 +33388,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33345,7 +33421,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33364,21 +33440,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(decorators, modifiers, parameters, type); @@ -33386,14 +33462,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33402,7 +33478,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33410,10 +33486,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33423,7 +33499,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33434,30 +33510,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33466,16 +33542,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33486,9 +33562,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33497,51 +33573,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33554,10 +33630,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -33566,10 +33642,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33578,21 +33654,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33601,10 +33677,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -33614,34 +33690,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -33650,89 +33726,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -33740,48 +33816,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -33791,18 +33867,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -33810,15 +33886,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -33834,9 +33910,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -33850,17 +33926,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -33889,7 +33965,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -33903,35 +33979,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -33941,7 +34017,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -33949,17 +34025,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -33980,65 +34056,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34049,19 +34125,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34079,10 +34155,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34095,10 +34171,10 @@ var ts; setDecoratorContext(/*val*/ false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos); + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -34106,9 +34182,9 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) { + function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -34134,7 +34210,7 @@ var ts; // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -34148,12 +34224,12 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then @@ -34162,13 +34238,13 @@ var ts; // Note: we call reScanGreaterToken so that we get an appropriately merged token // for cases like `> > =` becoming `>>=` if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } // It wasn't an assignment or a lambda. This is a conditional expression: return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34204,8 +34280,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher()), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34213,8 +34289,8 @@ var ts; return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, disallowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -34224,14 +34300,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34239,53 +34315,53 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? - parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) : - tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); }); + return triState === 1 /* Tristate.True */ ? + parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } // True -> We definitely expect a parenthesized arrow function here. // False -> There *cannot* be a parenthesized arrow function here. // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34294,102 +34370,102 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - return 1 /* True */; + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function parsePossibleParenthesizedArrowFunctionExpression() { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction); + var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, asyncModifier); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); } } return undefined; @@ -34398,26 +34474,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity, disallowReturnTypeInArrowFunction) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34427,7 +34503,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34444,28 +34520,11 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - // Given: - // x ? y => ({ y }) : z => ({ z }) - // We try to parse the body of the first arrow function by looking at: - // ({ y }) : z => ({ z }) - // This is a valid arrow function with "z" as the return type. - // - // But, if we're in the true side of a conditional expression, this colon - // terminates the expression, so we cannot allow a return type if we aren't - // certain whether or not the preceding text was parsed as a parameter list. - // - // For example, - // a() ? (b: number, c?: string): void => d() : e - // is determined by isParenthesizedArrowFunctionExpression to unambiguously - // be an arrow expression, so we allow a return type. - if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) { - return undefined; - } - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34480,31 +34539,31 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) : parseIdentifier(); var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync, disallowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + function parseArrowFunctionExpressionBody(isAsync) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34521,28 +34580,28 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }) - : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } function parseConditionalExpressionRest(leftOperand, pos) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher() + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -34550,7 +34609,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -34579,16 +34638,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -34609,7 +34668,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -34637,7 +34696,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -34670,7 +34729,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -34687,10 +34746,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -34715,23 +34774,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -34754,18 +34813,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -34786,17 +34845,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -34837,29 +34896,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -34921,19 +34980,19 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -34941,11 +35000,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -34971,11 +35030,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -34986,11 +35045,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35000,13 +35059,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35020,15 +35079,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35038,14 +35097,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the higher @@ -35057,21 +35116,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35079,8 +35138,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35101,60 +35160,60 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : - scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* SyntaxKind.EqualsToken */ ? undefined : + scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35167,11 +35226,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35184,36 +35243,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35234,8 +35293,8 @@ var ts; } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35244,7 +35303,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35255,30 +35314,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35293,14 +35352,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35309,7 +35368,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35317,9 +35376,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35332,7 +35391,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35340,22 +35399,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(31 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35368,58 +35427,34 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` - // These tokens can't follow in a call expression, nor can they start an - // expression. So, consider the type argument list part of an instantiation - // expression. - // falls through - case 27 /* CommaToken */: // foo, - case 24 /* DotToken */: // foo. - case 28 /* QuestionDotToken */: // foo?. - case 21 /* CloseParenToken */: // foo) - case 23 /* CloseBracketToken */: // foo] - case 58 /* ColonToken */: // foo: - case 26 /* SemicolonToken */: // foo; - case 57 /* QuestionToken */: // foo? - case 34 /* EqualsEqualsToken */: // foo == - case 36 /* EqualsEqualsEqualsToken */: // foo === - case 35 /* ExclamationEqualsToken */: // foo != - case 37 /* ExclamationEqualsEqualsToken */: // foo !== - case 55 /* AmpersandAmpersandToken */: // foo && - case 56 /* BarBarToken */: // foo || - case 60 /* QuestionQuestionToken */: // foo ?? - case 52 /* CaretToken */: // foo ^ - case 50 /* AmpersandToken */: // foo & - case 51 /* BarToken */: // foo | - case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; } - // Treat anything else as an expression. - return false; + // Consider something a type argument list only if the following token can't start an expression. + return !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35427,21 +35462,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35449,21 +35484,21 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); + var expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -35471,34 +35506,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { + var expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35507,18 +35542,18 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); - var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }) : undefined; + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); + var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful. node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); - var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); + parseExpected(58 /* SyntaxKind.ColonToken */); + var initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker @@ -35531,10 +35566,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35548,17 +35583,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -35569,20 +35604,20 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -35590,13 +35625,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -35609,9 +35644,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -35620,7 +35655,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -35632,58 +35667,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -35691,26 +35726,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { - var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); - parseExpected(21 /* CloseParenToken */); + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { + var expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35718,10 +35753,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35729,7 +35764,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -35737,47 +35772,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -35786,7 +35821,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -35806,25 +35841,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -35836,7 +35871,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -35847,9 +35882,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -35870,25 +35905,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -35911,44 +35946,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -35961,51 +35996,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36015,7 +36050,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36024,68 +36059,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36094,7 +36129,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -36117,16 +36152,16 @@ var ts; if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { var node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -36135,33 +36170,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36170,7 +36205,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36181,10 +36216,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* SyntaxKind.OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -36193,26 +36228,26 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36220,29 +36255,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36255,8 +36290,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36268,13 +36303,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36290,19 +36325,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36315,27 +36350,27 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36346,9 +36381,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); // Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker. node.typeParameters = typeParameters; @@ -36358,11 +36393,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36370,20 +36405,20 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); @@ -36391,21 +36426,21 @@ var ts; function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 173 /* SetAccessor */) + if (type && node.kind === 173 /* SyntaxKind.SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36422,7 +36457,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36432,24 +36467,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36463,7 +36498,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); } @@ -36478,7 +36513,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36491,7 +36526,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36508,17 +36543,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -36539,7 +36574,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -36547,33 +36582,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -36585,17 +36620,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36603,21 +36638,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -36625,17 +36660,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36651,45 +36686,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -36698,11 +36733,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36719,12 +36754,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -36735,9 +36770,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -36747,10 +36782,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36758,17 +36793,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -36779,37 +36814,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -36819,7 +36854,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -36827,7 +36862,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -36841,15 +36876,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -36858,21 +36893,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); - var value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -36886,15 +36921,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -36912,26 +36947,26 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -36947,8 +36982,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -36961,17 +36996,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -36996,10 +37031,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37034,15 +37069,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37062,26 +37097,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37093,13 +37128,13 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -37143,11 +37178,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37159,10 +37194,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37171,16 +37206,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); - var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); - while (token() === 80 /* PrivateIdentifier */) { + var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37188,9 +37223,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37200,9 +37235,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37250,7 +37285,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37263,16 +37298,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37280,35 +37315,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37316,10 +37351,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37338,7 +37373,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37367,26 +37402,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37394,14 +37429,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37409,7 +37444,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37458,7 +37493,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37496,7 +37531,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37511,31 +37546,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -37547,8 +37582,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37562,32 +37597,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -37604,7 +37639,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -37616,17 +37651,17 @@ var ts; // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false) + ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -37637,8 +37672,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -37666,35 +37701,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -37710,12 +37745,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -37726,12 +37761,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -37752,8 +37787,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -37775,14 +37810,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -37801,21 +37836,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -37849,7 +37884,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -37866,7 +37901,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -37890,11 +37925,11 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -37906,7 +37941,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -37917,9 +37952,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -37928,7 +37963,8 @@ var ts; if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + var end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -37943,18 +37979,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -37962,26 +37998,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -37989,15 +38025,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38009,7 +38045,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38017,9 +38053,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38036,7 +38072,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38051,7 +38087,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38064,16 +38100,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38081,7 +38117,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38098,7 +38134,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38253,9 +38289,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38510,7 +38546,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -38525,7 +38561,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -38563,7 +38599,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -38616,7 +38652,7 @@ var ts; })(IncrementalParser || (IncrementalParser = {})); /** @internal */ function isDeclarationFileName(fileName) { - return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]); + return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions); } ts.isDeclarationFileName = isDeclarationFileName; function parseResolutionMode(mode, pos, end, reportDiagnostic) { @@ -38743,18 +38779,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -38788,15 +38824,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -38839,10 +38875,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -38862,11 +38898,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -38937,6 +38973,7 @@ var ts; ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -39169,18 +39206,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39189,7 +39226,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; var commandOptionsWithoutBuild = [ // CommandLine only options @@ -39272,7 +39309,7 @@ var ts; es2020: ts.ModuleKind.ES2020, es2022: ts.ModuleKind.ES2022, esnext: ts.ModuleKind.ESNext, - node12: ts.ModuleKind.Node12, + node16: ts.ModuleKind.Node16, nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -39447,15 +39484,15 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -39626,7 +39663,7 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, - node12: ts.ModuleResolutionKind.Node12, + node16: ts.ModuleResolutionKind.Node16, nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -39869,8 +39906,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, @@ -40102,7 +40139,7 @@ var ts; affectsModuleResolution: true, description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: ts.Diagnostics.Language_and_Environment, - defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; /* @internal */ @@ -40223,7 +40260,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40248,8 +40285,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40308,11 +40345,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40341,14 +40378,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40359,7 +40396,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -40694,7 +40731,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -40734,7 +40771,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -40801,16 +40838,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -40825,16 +40862,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -40851,7 +40888,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41043,10 +41080,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41097,19 +41134,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41118,25 +41155,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41191,7 +41228,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -41536,8 +41573,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -41778,11 +41815,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -41926,7 +41963,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -41960,13 +41997,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -41989,7 +42026,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42067,7 +42104,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42124,7 +42161,8 @@ var ts; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; - Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; + Extensions[Extensions["TsOnly"] = 5] = "TsOnly"; })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -42134,7 +42172,7 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { var _a; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -42142,7 +42180,8 @@ var ts; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations: failedLookupLocations + failedLookupLocations: failedLookupLocations, + resolutionDiagnostics: diagnostics }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -42219,7 +42258,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42282,7 +42321,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -42337,13 +42376,24 @@ var ts; // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions }; + var diagnostics = []; + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -42362,7 +42412,7 @@ var ts; isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); @@ -42428,7 +42478,7 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getDefaultNodeResolutionFeatures(options) { - return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -42445,6 +42495,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ts.emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: ts.noop }; return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { @@ -42487,7 +42539,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -42638,7 +42690,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -42673,7 +42725,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -42786,8 +42838,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -42807,8 +42859,8 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ts.ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ts.ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ts.ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -42820,10 +42872,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43026,7 +43078,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43042,15 +43094,15 @@ var ts; // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; - NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default"; + NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default"; NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault"; NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); - function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { - return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); } function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43069,15 +43121,34 @@ var ts; return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + var extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) + extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) + extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). + var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + var diagnostics = []; var state = { compilerOptions: compilerOptions, host: host, @@ -43085,10 +43156,12 @@ var ts; failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -43148,7 +43221,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43215,7 +43288,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43234,7 +43307,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43251,7 +43324,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43261,9 +43334,9 @@ var ts; } } function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) { var result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; + return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } @@ -43279,53 +43352,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: + case Extensions.TsOnly: + var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43384,6 +43459,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features: features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: ts.noop }; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); @@ -43470,6 +43547,8 @@ var ts; packageJsonInfoCache: packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: ts.noop }; var parts = ts.getPathComponents(fileName); parts.pop(); @@ -43533,6 +43612,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -43605,14 +43685,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; + case Extensions.TsOnly: + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -43649,7 +43731,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -43758,7 +43840,6 @@ var ts; function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { return loadModuleFromTargetImportOrExport; function loadModuleFromTargetImportOrExport(target, subpath, pattern) { - var _a, _b; if (typeof target === "string") { if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { if (state.traceEnabled) { @@ -43795,13 +43876,16 @@ var ts; } return toSearchResult(/*value*/ undefined); } - var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) + return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); } else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null if (!Array.isArray(target)) { - for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { - var key = _c[_i]; + for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) { + var key = _a[_i]; if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { var subTarget = target[key]; var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); @@ -43819,8 +43903,8 @@ var ts; } return toSearchResult(/*value*/ undefined); } - for (var _d = 0, target_2 = target; _d < target_2.length; _d++) { - var elem = target_2[_d]; + for (var _b = 0, target_2 = target; _b < target_2.length; _b++) { + var elem = target_2[_b]; var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); if (result) { return result; @@ -43838,6 +43922,128 @@ var ts; trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(/*value*/ undefined); + function toAbsolutePath(path) { + var _a, _b; + if (path === undefined) + return path; + return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a))); + } + function combineDirectoryPath(root, dir) { + return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir)); + } + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) { + var _a, _b, _c, _d; + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames }); + var commonSourceDirGuesses = []; + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory + var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts")); + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + var fragment = ts.ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + var parts = ts.getPathComponents(fragment); + parts.pop(); // remove a directory + var commonDir_1 = ts.getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir_1); + fragment = ts.ensureTrailingDirectorySeparator(commonDir_1); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(ts.createCompilerDiagnostic(isImports + ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath)); + } + for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) { + var commonSourceDirGuess = commonSourceDirGuesses_1[_i]; + var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) { + var candidateDir = candidateDirectories_1[_e]; + if (ts.startsWith(finalPath, candidateDir)) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator + var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; + for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { + var ext = jsAndDtsExtensions_1[_f]; + if (ts.fileExtensionIs(possibleInputBase, ext)) { + var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) { + var possibleExt = inputExts_1[_g]; + var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state))); + } + } + } + } + } + } + } + } + return undefined; + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) { + var _a, _b; + // Config file ouput paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess; + var candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } /* @internal */ @@ -43985,7 +44191,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44028,11 +44234,12 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -44075,9 +44282,10 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; /** @@ -44103,14 +44311,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44121,34 +44329,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44156,21 +44364,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44178,16 +44386,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -44207,7 +44415,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -44218,7 +44426,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -44292,8 +44500,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -44315,7 +44523,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -44342,7 +44550,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -44362,33 +44570,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -44414,36 +44622,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(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; @@ -44462,14 +44670,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -44496,11 +44704,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -44512,20 +44720,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -44545,7 +44753,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -44553,9 +44761,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -44568,7 +44776,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -44582,9 +44790,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -44608,11 +44816,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -44639,7 +44847,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -44672,21 +44880,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -44694,22 +44902,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -44717,21 +44925,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -44745,10 +44953,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -44758,8 +44966,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -44782,59 +44990,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -44844,47 +45052,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -44898,22 +45106,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -44921,7 +45129,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -44937,7 +45145,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -44948,68 +45156,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45021,7 +45229,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45033,7 +45241,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45048,28 +45256,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45079,7 +45287,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45098,8 +45306,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45113,7 +45321,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45164,12 +45372,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45191,7 +45399,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -45208,7 +45416,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -45279,7 +45487,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -45313,7 +45521,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -45342,7 +45550,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -45361,9 +45569,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -45387,7 +45595,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -45396,12 +45604,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -45409,16 +45617,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -45426,7 +45634,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -45437,15 +45645,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -45455,14 +45663,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -45511,9 +45719,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -45530,7 +45738,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -45544,7 +45752,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -45555,10 +45763,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -45583,7 +45791,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -45611,7 +45819,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -45640,7 +45848,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -45652,28 +45860,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -45699,8 +45907,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -45738,76 +45946,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -45824,9 +46032,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -45840,46 +46048,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -45906,17 +46114,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -45924,25 +46132,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -45950,8 +46158,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -45961,10 +46169,10 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } @@ -45978,7 +46186,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */ || prop.name.kind !== 79 /* SyntaxKind.Identifier */) { continue; } var identifier = prop.name; @@ -45990,9 +46198,9 @@ 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 === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + var currentKind = prop.kind === 296 /* SyntaxKind.PropertyAssignment */ || prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || prop.kind === 169 /* SyntaxKind.MethodDeclaration */ + ? 1 /* ElementKind.Property */ + : 2 /* ElementKind.Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -46000,17 +46208,17 @@ var ts; } } } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46018,10 +46226,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46047,9 +46255,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46060,8 +46268,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46069,29 +46277,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46109,24 +46317,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46168,7 +46376,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46179,7 +46387,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -46218,10 +46426,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -46231,7 +46439,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -46247,7 +46455,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -46260,7 +46468,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -46318,11 +46526,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -46332,7 +46540,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -46380,7 +46588,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -46389,28 +46597,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -46422,28 +46630,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -46454,94 +46662,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -46551,73 +46759,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -46628,27 +46836,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -46668,28 +46876,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -46708,13 +46916,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -46725,15 +46933,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -46754,13 +46962,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -46772,11 +46980,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -46790,17 +46998,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -46809,19 +47017,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -46829,7 +47037,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -46838,10 +47046,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -46860,7 +47068,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -46881,7 +47089,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -46893,7 +47101,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -46906,7 +47114,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -46924,13 +47132,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -46944,7 +47152,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -46956,12 +47164,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -46971,27 +47179,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -47010,7 +47218,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47025,7 +47233,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47070,12 +47278,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47091,7 +47299,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47104,19 +47312,19 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47128,72 +47336,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -47207,45 +47415,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -47259,9 +47467,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -47285,17 +47493,17 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } @@ -47380,32 +47588,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -47494,7 +47702,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -47628,24 +47836,24 @@ var ts; TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = new ts.Map(ts.getEntries({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ + string: 1 /* TypeFacts.TypeofEQString */, + number: 2 /* TypeFacts.TypeofEQNumber */, + bigint: 4 /* TypeFacts.TypeofEQBigInt */, + boolean: 8 /* TypeFacts.TypeofEQBoolean */, + symbol: 16 /* TypeFacts.TypeofEQSymbol */, + undefined: 65536 /* TypeFacts.EQUndefined */, + object: 32 /* TypeFacts.TypeofEQObject */, + function: 64 /* TypeFacts.TypeofEQFunction */ })); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -47751,10 +47959,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -47779,8 +47987,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -47795,7 +48003,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -47829,7 +48037,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -47843,20 +48051,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -47908,10 +48116,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48006,7 +48214,7 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); @@ -48027,13 +48235,13 @@ var ts; getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48119,7 +48327,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48156,10 +48364,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -48230,32 +48438,32 @@ var ts; var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var nonInferrableAnyType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 65536 /* ObjectFlags.ContainsWideningType */); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -48265,27 +48473,28 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonInferrableType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48293,7 +48502,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48301,11 +48510,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -48453,7 +48662,7 @@ var ts; var enumRelation = new ts.Map(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -48464,7 +48673,7 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; @@ -48610,7 +48819,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -48624,44 +48833,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -48693,13 +48902,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -48707,7 +48916,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -48730,7 +48939,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -48739,8 +48948,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -48751,9 +48960,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -48796,7 +49005,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -48838,7 +49047,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -48847,7 +49056,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -48862,9 +49071,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -48897,7 +49106,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -48907,17 +49116,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -48937,8 +49146,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -48952,7 +49161,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -48966,17 +49175,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -48990,7 +49199,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49006,19 +49215,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49033,9 +49242,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49063,7 +49272,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49078,7 +49287,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49101,19 +49310,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49138,7 +49347,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49153,30 +49362,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -49229,35 +49438,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -49272,17 +49481,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -49302,13 +49511,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -49317,12 +49526,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -49332,20 +49541,20 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -49360,7 +49569,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -49368,11 +49577,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -49388,39 +49597,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -49428,7 +49637,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -49437,7 +49646,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -49452,20 +49661,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -49473,7 +49682,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -49481,8 +49690,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -49507,7 +49716,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -49544,7 +49753,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -49571,7 +49780,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -49594,22 +49803,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -49621,10 +49830,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -49638,31 +49847,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -49675,7 +49884,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -49719,7 +49928,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -49731,10 +49940,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -49744,9 +49953,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -49765,9 +49974,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -49778,20 +49987,20 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -49813,7 +50022,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -49830,15 +50039,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -49848,29 +50057,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -49891,13 +50100,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -49922,22 +50131,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { @@ -49951,7 +50160,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -49964,7 +50173,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -49976,14 +50185,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -49993,7 +50202,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -50010,7 +50219,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50042,7 +50251,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50050,7 +50259,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50078,12 +50287,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50127,7 +50336,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50142,7 +50351,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50150,7 +50359,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50166,7 +50375,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50175,7 +50384,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -50184,7 +50393,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -50205,7 +50414,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -50222,7 +50431,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -50302,7 +50511,7 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -50314,7 +50523,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -50322,31 +50531,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -50357,38 +50566,38 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol) { var links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } return undefined; @@ -50431,7 +50640,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -50439,7 +50648,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -50450,7 +50659,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -50471,7 +50680,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -50494,22 +50703,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -50519,7 +50728,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -50540,9 +50749,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -50550,9 +50759,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -50586,7 +50795,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -50594,8 +50803,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -50609,8 +50818,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -50630,7 +50839,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -50651,7 +50860,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -50682,7 +50891,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -50742,7 +50951,7 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; @@ -50751,9 +50960,6 @@ var ts; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) { - error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -50806,7 +51012,7 @@ var ts; var tsExtension = ts.tryExtractTSExtension(moduleReference); var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 || moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -50817,27 +51023,27 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); var suggestedExt = (_h = suggestedExtensions.find(function (_a) { var actualExt = _a[0], _importExt = _a[1]; return host.fileExists(absoluteRef_1 + actualExt); })) === null || _h === void 0 ? void 0 : _h[1]; if (suggestedExt) { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -50869,27 +51075,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -50903,7 +51109,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -50922,12 +51128,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -50959,7 +51165,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51011,15 +51217,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51034,7 +51240,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51069,7 +51275,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51158,21 +51364,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -51196,7 +51402,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -51217,7 +51423,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -51225,7 +51431,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -51235,7 +51441,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -51259,16 +51465,16 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol)); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && !getTypeOnlyAliasDeclaration(symbol)); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -51291,7 +51497,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -51305,7 +51511,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -51315,11 +51521,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -51351,14 +51557,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -51376,12 +51582,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -51390,9 +51596,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -51403,7 +51609,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -51422,7 +51628,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -51433,7 +51639,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -51477,9 +51683,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -51487,7 +51693,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -51531,7 +51737,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -51546,10 +51752,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -51560,16 +51766,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -51599,7 +51805,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -51623,14 +51829,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -51659,7 +51865,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -51668,28 +51874,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -51697,24 +51903,24 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + else if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement && ts.isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); @@ -51738,83 +51944,83 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -51822,7 +52028,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -51840,17 +52046,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 814775659 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -51884,12 +52090,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -51911,7 +52117,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -51946,62 +52152,62 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52015,66 +52221,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52084,19 +52290,19 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52113,8 +52319,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52122,43 +52328,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52166,39 +52372,63 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); + var name = typeParameterToName(newParam, context); + var newTypeVariable = ts.factory.createTypeReferenceNode(name); + context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var saveInferTypeParameters_1 = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters_1; + var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive + // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType + // inner conditional runs the check the user provided on the check type (distributively) and returns the result + // checkType extends infer T ? T extends checkType ? T extends extendsType ? trueType : falseType : never : never; + // this is potentially simplifiable to + // checkType extends infer T ? T extends checkType & extendsType ? trueType : falseType : never; + // but that may confuse users who read the output more. + // On the other hand, + // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; + // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); + } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -52209,7 +52439,7 @@ var ts; return typeToTypeNodeHelper(type, context); } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -52217,27 +52447,27 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -52246,16 +52476,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */ && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -52264,7 +52494,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -52280,26 +52510,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -52311,7 +52541,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -52370,20 +52600,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -52392,8 +52622,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -52405,27 +52635,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -52433,7 +52663,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -52441,23 +52671,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -52481,8 +52711,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -52494,8 +52724,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -52559,17 +52789,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -52579,16 +52809,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -52599,10 +52829,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -52612,19 +52842,19 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; - if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { + if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* CheckFlags.Late */ && isLateBoundName(propertySymbol.escapedName)) { if (propertySymbol.declarations) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { @@ -52647,12 +52877,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -52666,12 +52896,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -52680,11 +52910,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -52703,12 +52933,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -52717,7 +52947,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -52742,7 +52972,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -52777,22 +53007,22 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -52800,7 +53030,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); var thisParameter = tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); @@ -52808,11 +53038,11 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -52823,28 +53053,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -52868,7 +53098,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -52882,29 +53112,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */); - } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -52924,7 +53151,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -52933,9 +53160,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -52945,8 +53172,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -52956,7 +53183,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -52975,8 +53202,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -52995,7 +53222,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53025,7 +53252,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53040,11 +53267,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53064,11 +53291,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53120,7 +53347,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53128,8 +53355,8 @@ var ts; return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier; } 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 - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53138,7 +53365,7 @@ var ts; var targetFile = ts.getSourceFileOfModule(chain[0]); var specifier = void 0; var assertion = void 0; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) { specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext); @@ -53150,9 +53377,9 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -53211,16 +53438,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -53239,7 +53466,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -53251,7 +53478,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -53264,9 +53491,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -53275,23 +53502,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -53308,7 +53535,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -53316,13 +53543,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -53334,38 +53561,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -53394,7 +53621,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -53404,8 +53631,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -53439,7 +53666,7 @@ var ts; return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -53451,7 +53678,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_6) { return result_6; @@ -53460,20 +53687,30 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; return result; } + function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { + var typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; + } + return false; + } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -53492,20 +53729,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -53523,17 +53760,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -53547,11 +53784,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -53568,16 +53805,16 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -53586,7 +53823,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -53601,17 +53838,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -53642,8 +53879,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -53656,10 +53893,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -53674,16 +53911,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -53700,7 +53937,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -53716,9 +53953,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -53814,11 +54051,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -53871,37 +54108,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -53913,21 +54150,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -53939,14 +54176,14 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -53972,7 +54209,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -53980,11 +54217,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -53997,20 +54234,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54019,18 +54256,18 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54043,7 +54280,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54057,23 +54294,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54089,14 +54326,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54107,10 +54344,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); @@ -54119,7 +54356,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54132,7 +54369,7 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); @@ -54140,7 +54377,7 @@ var ts; var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -54156,12 +54393,12 @@ var ts; })))]); addResult(ts.factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { addResult(ts.factory.createEnumDeclaration( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -54173,22 +54410,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -54222,7 +54459,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -54243,15 +54480,15 @@ var ts; var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -54300,7 +54537,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -54327,17 +54564,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -54380,15 +54617,15 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -54396,19 +54633,19 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -54419,7 +54656,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, @@ -54428,30 +54665,30 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -54459,21 +54696,21 @@ var ts; // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -54482,9 +54719,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -54492,16 +54729,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -54516,18 +54753,18 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -54542,7 +54779,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -54556,7 +54793,7 @@ var ts; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -54572,7 +54809,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -54587,17 +54824,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -54617,11 +54854,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -54632,25 +54869,25 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -54659,8 +54896,8 @@ var ts; /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); @@ -54669,19 +54906,19 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -54691,7 +54928,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -54700,7 +54937,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -54708,13 +54945,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -54735,7 +54972,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -54771,15 +55008,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -54789,22 +55026,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -54822,7 +55059,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -54831,17 +55068,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -54860,14 +55097,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -54877,10 +55114,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -54892,25 +55129,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -54918,27 +55155,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -54950,9 +55187,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -54966,9 +55203,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -54981,17 +55218,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -55008,84 +55245,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55094,11 +55331,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55122,7 +55359,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55171,23 +55408,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -55204,12 +55441,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -55234,28 +55471,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -55263,9 +55500,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -55280,7 +55517,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -55295,15 +55532,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -55339,34 +55576,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -55377,18 +55614,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -55405,7 +55642,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -55413,7 +55650,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -55425,7 +55662,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -55439,9 +55676,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 32768 /* TypeFlags.Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -55452,11 +55689,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -55467,11 +55704,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -55493,11 +55730,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -55509,8 +55746,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -55528,7 +55765,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -55551,14 +55788,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -55587,7 +55824,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -55609,7 +55846,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -55669,7 +55906,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -55708,7 +55945,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -55738,12 +55975,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -55767,7 +56004,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -55823,13 +56060,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -55841,7 +56078,7 @@ var ts; var _a; var exportedMember = members_4.get(name); if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -55874,9 +56111,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -55888,16 +56125,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -55917,7 +56154,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -55935,7 +56172,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -55945,11 +56182,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -55959,7 +56196,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -55967,18 +56204,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -55992,7 +56229,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -56006,7 +56243,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56016,14 +56253,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56040,7 +56277,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56064,14 +56301,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56112,15 +56349,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56139,7 +56376,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56153,10 +56390,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -56179,7 +56416,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -56188,7 +56425,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -56213,11 +56450,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -56252,10 +56489,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -56270,8 +56507,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -56292,21 +56529,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -56314,13 +56551,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -56341,7 +56578,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -56362,7 +56599,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -56375,7 +56612,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -56384,7 +56621,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -56395,15 +56632,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -56411,56 +56648,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -56483,7 +56720,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -56494,46 +56731,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -56544,7 +56781,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -56557,9 +56794,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -56576,7 +56813,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -56587,10 +56824,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -56603,7 +56840,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -56626,7 +56863,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -56634,7 +56871,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -56643,13 +56880,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -56689,19 +56926,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -56711,7 +56948,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -56722,26 +56959,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -56766,7 +57003,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -56791,7 +57028,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -56799,15 +57036,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -56847,8 +57084,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -56856,8 +57093,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -56871,7 +57108,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -56885,8 +57122,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -56907,7 +57144,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -56926,7 +57163,7 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { @@ -56941,7 +57178,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -56949,19 +57186,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -56976,11 +57213,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -56989,23 +57226,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57017,15 +57254,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57051,22 +57288,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57078,22 +57315,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57119,7 +57356,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57135,14 +57372,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -57179,8 +57416,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -57189,7 +57426,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -57208,9 +57445,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -57235,10 +57472,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -57249,7 +57486,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -57258,7 +57495,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -57307,7 +57544,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -57316,10 +57553,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -57337,9 +57574,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -57365,10 +57602,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -57384,8 +57621,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -57395,7 +57632,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -57412,7 +57649,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -57420,7 +57657,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -57456,8 +57693,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -57492,7 +57729,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -57502,24 +57739,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -57531,7 +57768,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -57544,10 +57781,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -57555,11 +57792,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -57574,7 +57811,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -57737,12 +57974,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -57764,11 +58001,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -57793,8 +58030,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -57802,7 +58039,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -57817,7 +58054,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -57839,7 +58076,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -57849,7 +58086,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -57888,18 +58125,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -57912,7 +58149,8 @@ var ts; if (symbol === globalThisSymbol) { var varsOnly_1 = new ts.Map(); members.forEach(function (p) { - if (!(p.flags & 418 /* BlockScoped */)) { + var _a; + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -57921,10 +58159,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -57940,8 +58178,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -57950,16 +58188,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -57977,20 +58215,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58011,11 +58249,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58025,29 +58263,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58067,7 +58305,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58095,13 +58333,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58114,12 +58352,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58127,7 +58365,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58137,8 +58375,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -58164,7 +58402,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -58172,8 +58410,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -58189,20 +58427,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -58210,34 +58448,34 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -58245,7 +58483,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -58254,7 +58492,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58278,7 +58516,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -58288,13 +58526,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -58313,7 +58551,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -58332,9 +58570,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -58395,7 +58633,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -58413,11 +58651,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -58427,7 +58665,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { hasDisjointDomainType = true; } } @@ -58439,7 +58677,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -58449,11 +58687,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -58478,7 +58716,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -58488,13 +58726,14 @@ var ts; // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of // nesting, so it is effectively just a safety stop. - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + var identity_1 = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) { + stack.push(identity_1); result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -58514,13 +58753,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -58540,23 +58779,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -58567,11 +58806,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -58630,7 +58869,7 @@ var ts; var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -58638,7 +58877,7 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !objectType.declaration.questionToken && !objectType.declaration.nameType); } @@ -58648,17 +58887,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ScriptTarget.ES2020 */) : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ScriptTarget.ES2015 */) : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -58673,21 +58912,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -58700,7 +58939,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -58718,41 +58957,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -58794,18 +59033,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -58818,7 +59057,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -58852,7 +59091,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -58861,15 +59100,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -58879,7 +59118,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -58890,23 +59129,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -58921,7 +59160,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58941,15 +59180,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -58992,13 +59231,13 @@ var ts; } function isApplicableIndexType(source, target) { // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index - // signature applies to types assignable to 'number' and numeric string literal types. + // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59049,17 +59288,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59074,7 +59313,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59092,7 +59331,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59141,7 +59380,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59153,7 +59392,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -59163,19 +59402,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -59187,25 +59426,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -59227,7 +59466,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -59236,7 +59475,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -59269,7 +59508,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -59281,18 +59520,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -59364,26 +59603,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -59410,7 +59649,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -59420,12 +59659,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -59434,7 +59673,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -59528,8 +59767,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -59543,7 +59782,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -59561,7 +59800,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -59576,8 +59815,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -59588,13 +59827,13 @@ var ts; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -59619,27 +59858,27 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -59664,10 +59903,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -59676,7 +59915,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -59704,7 +59943,7 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -59718,13 +59957,13 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; @@ -59746,7 +59985,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -59757,13 +59996,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -59798,14 +60037,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -59836,12 +60075,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -59876,9 +60115,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -59890,21 +60129,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -59926,10 +60165,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -59937,14 +60176,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -59960,7 +60199,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -59971,22 +60210,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -59996,27 +60235,41 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); } } + // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the + // template type XXX, K has an added constraint of number | `${number}`. + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { + var mappedType = getTypeFromTypeNode(parent); + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + var typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + var constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = ts.append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60072,7 +60325,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60084,13 +60337,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60131,9 +60384,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60143,7 +60396,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -60154,13 +60407,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -60196,9 +60449,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -60263,7 +60516,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -60301,20 +60554,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -60323,14 +60576,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -60339,18 +60592,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -60359,28 +60612,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -60393,33 +60646,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -60437,7 +60690,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -60447,8 +60700,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -60456,8 +60709,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -60467,7 +60720,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -60485,26 +60738,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -60523,10 +60776,10 @@ var ts; var _loop_15 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -60541,7 +60794,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -60556,12 +60809,12 @@ var ts; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -60571,13 +60824,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -60629,19 +60882,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -60675,18 +60928,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -60700,20 +60953,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -60731,11 +60984,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -60749,7 +61002,7 @@ var ts; var _loop_16 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; @@ -60759,17 +61012,17 @@ var ts; } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -60788,7 +61041,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -60797,37 +61050,37 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; @@ -60851,11 +61104,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -60864,8 +61117,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -60902,20 +61155,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -60926,41 +61179,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -60978,10 +61231,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -60994,10 +61247,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61011,11 +61264,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61032,7 +61285,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61044,7 +61297,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61053,7 +61306,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61082,12 +61335,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61116,37 +61369,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { + if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -61158,21 +61411,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -61184,8 +61437,8 @@ var ts; var constituents = getCrossProductIntersections(typeSet); // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions). - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -61196,12 +61449,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -61214,7 +61467,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -61222,7 +61475,7 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; @@ -61236,13 +61489,13 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -61274,7 +61527,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -61290,8 +61543,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -61311,12 +61564,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -61328,11 +61581,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -61342,14 +61595,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -61367,16 +61620,16 @@ var ts; function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) + return type.flags & 1048576 /* TypeFlags.Union */ ? isPossiblyReducibleByInstantiation(type) ? getIndexTypeForGenericType(type, stringsOnly) : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -61387,21 +61640,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -61418,7 +61671,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -61437,10 +61690,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -61451,13 +61704,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -61470,7 +61723,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -61483,35 +61736,35 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -61519,13 +61772,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -61546,16 +61799,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -61570,26 +61823,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -61599,7 +61852,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -61607,12 +61860,12 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -61624,33 +61877,33 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -61658,21 +61911,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -61694,20 +61947,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -61724,10 +61977,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -61745,62 +61998,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -61825,7 +62078,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -61839,17 +62092,20 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } } - // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where + // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P. + // For example, for an index access { [P in K]: Box }[X], we construct the type Box. + if (isGenericMappedType(objectType)) { + var nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + } } return type[cache] = type; } @@ -61859,19 +62115,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -61881,7 +62137,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -61889,12 +62145,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -61905,33 +62161,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -61943,12 +62199,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -61964,11 +62220,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -61976,8 +62232,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -61987,7 +62243,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -61999,11 +62255,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62068,7 +62324,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62086,7 +62342,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62102,15 +62358,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -62128,7 +62384,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -62139,7 +62395,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -62167,14 +62423,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -62202,7 +62458,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -62225,7 +62481,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -62268,7 +62524,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -62281,7 +62537,7 @@ var ts; var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references @@ -62304,7 +62560,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -62318,7 +62574,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -62334,7 +62590,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -62347,7 +62603,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -62356,13 +62612,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -62382,13 +62638,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62397,7 +62653,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -62407,31 +62663,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -62441,7 +62697,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -62455,7 +62711,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -62470,11 +62726,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -62487,23 +62743,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62521,7 +62777,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -62532,39 +62788,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -62574,9 +62830,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -62592,20 +62848,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -62627,17 +62883,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -62653,99 +62909,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -62783,9 +63039,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -62794,22 +63050,22 @@ var ts; } } return type; - case 2 /* Function */: + case 2 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 3 /* TypeMapKind.Composite */: + case 4 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 3 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return { kind: 0 /* TypeMapKind.Simple */, source: source, target: target }; } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return { kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }; } function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + return { kind: 2 /* TypeMapKind.Function */, func: func }; } function makeCompositeTypeMapper(kind, mapper1, mapper2) { return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; @@ -62825,16 +63081,16 @@ var ts; return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(3 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -62867,7 +63123,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -62879,7 +63135,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -62888,7 +63144,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -62902,12 +63158,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -62920,8 +63176,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -62942,8 +63198,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -62952,8 +63208,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -62962,7 +63218,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -62971,15 +63227,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -62990,9 +63246,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63014,11 +63270,11 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -63038,7 +63294,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63047,14 +63303,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63064,11 +63320,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63078,13 +63334,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63093,7 +63349,7 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; @@ -63118,7 +63374,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -63138,7 +63394,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -63151,62 +63407,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -63216,11 +63472,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -63230,15 +63486,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -63259,35 +63515,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -63301,17 +63557,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -63320,7 +63576,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -63330,13 +63586,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -63353,11 +63609,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -63395,7 +63651,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -63405,35 +63661,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -63457,7 +63713,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -63475,7 +63731,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -63492,7 +63748,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -63502,7 +63758,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -63519,7 +63775,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -63539,8 +63795,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -63564,7 +63820,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -63630,18 +63886,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -63666,7 +63922,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -63748,7 +64004,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -63758,7 +64014,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -63783,17 +64039,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -63815,7 +64071,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -63827,8 +64083,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -63844,16 +64100,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -63865,10 +64121,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -63880,7 +64136,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -63899,27 +64155,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* TypeFlags.Nullable */) === (getFalsyFlags(targetType) & 98304 /* TypeFlags.Nullable */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -63942,14 +64198,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -63964,21 +64220,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -64004,19 +64260,19 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64025,83 +64281,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; } return false; @@ -64117,38 +64373,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getReducedType(type) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) @@ -64177,19 +64433,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -64227,10 +64483,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -64275,24 +64531,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -64321,7 +64577,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -64334,7 +64590,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -64386,7 +64642,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperType && target !== markerSubType) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -64408,7 +64664,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -64456,7 +64712,7 @@ var ts; } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -64470,7 +64726,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -64479,19 +64735,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -64500,73 +64756,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -64585,10 +64841,10 @@ var ts; // // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. - if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -64598,10 +64854,9 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { - var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -64610,20 +64865,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -64642,25 +64897,22 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -64675,7 +64927,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -64683,19 +64935,19 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_19 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { @@ -64750,7 +65002,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -64773,28 +65025,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -64802,16 +65054,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64819,13 +65071,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -64833,7 +65085,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -64842,19 +65094,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64862,50 +65114,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64916,54 +65168,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64977,28 +65229,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); } - if (saved & 16 /* ReportsUnreliable */) { + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65014,42 +65266,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65057,30 +65309,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -65089,14 +65341,14 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; @@ -65106,29 +65358,29 @@ var ts; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -65136,18 +65388,18 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { + if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -65161,10 +65413,10 @@ var ts; // needs to have its constraint hoisted into an intersection with said type parameter, this way // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65176,20 +65428,20 @@ var ts; // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -65198,34 +65450,34 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65238,8 +65490,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -65254,7 +65506,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -65262,18 +65514,18 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65291,14 +65543,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -65317,12 +65569,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -65330,22 +65582,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65365,7 +65617,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -65375,12 +65627,12 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -65391,8 +65643,8 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { resetErrorInfo(saveErrorInfo); return result; @@ -65400,37 +65652,37 @@ var ts; } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source); - if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) { + if (!constraint || (sourceFlags & 262144 /* TypeFlags.TypeParameter */ && constraint.flags & 1 /* TypeFlags.Any */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* TypeFlags.NonPrimitive */), 3 /* RecursionFlags.Both */)) { resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65439,7 +65691,7 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65447,44 +65699,44 @@ var ts; } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */ && source.symbol === target.symbol) { + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -65493,15 +65745,15 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65514,7 +65766,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65524,7 +65776,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65533,7 +65785,7 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -65542,22 +65794,22 @@ var ts; return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -65567,41 +65819,41 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -65618,9 +65870,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -65628,7 +65880,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -65638,7 +65890,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -65665,8 +65917,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -65698,14 +65950,14 @@ var ts; var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -65720,7 +65972,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -65732,8 +65984,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -65742,7 +65994,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -65763,7 +66015,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -65780,7 +66032,7 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { @@ -65790,20 +66042,20 @@ var ts; return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -65830,40 +66082,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -65873,7 +66125,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -65881,10 +66133,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -65895,7 +66147,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -65906,7 +66158,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -65948,29 +66200,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -65981,38 +66233,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66020,12 +66272,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66035,14 +66287,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66051,18 +66303,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -66074,12 +66326,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66088,24 +66340,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66117,17 +66369,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -66136,18 +66388,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -66155,7 +66407,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66170,10 +66422,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -66199,18 +66451,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -66233,45 +66485,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66281,7 +66533,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66289,7 +66541,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -66306,14 +66558,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66324,46 +66576,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -66376,19 +66628,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -66397,7 +66649,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -66417,7 +66669,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -66452,12 +66704,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -66473,7 +66725,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -66489,14 +66741,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; var _loop_22 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -66507,22 +66759,22 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } @@ -66543,7 +66795,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -66554,34 +66806,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -66589,7 +66841,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -66625,12 +66877,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -66645,7 +66897,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } // Return the inherited type of the given property or undefined if property doesn't exist in a base class. function getTypeOfPropertyInBaseClass(property) { @@ -66663,13 +66915,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -66687,12 +66939,12 @@ var ts; function isDeeplyNestedType(type, stack, depth, maxDepth) { if (maxDepth === void 0) { maxDepth = 3; } if (depth >= maxDepth) { - var identity_1 = getRecursionIdentity(type); + var identity_2 = getRecursionIdentity(type); var count = 0; var lastTypeId = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (getRecursionIdentity(t) === identity_1) { + if (getRecursionIdentity(t) === identity_2) { // We only count occurrences with a higher type id than the previous occurrence, since higher // type ids are an indicator of newer instantiations caused by recursion. if (t.id >= lastTypeId) { @@ -66715,14 +66967,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -66732,49 +66984,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -66805,14 +67057,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -66823,12 +67075,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -66836,7 +67088,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66848,7 +67100,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66862,10 +67114,10 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -66896,20 +67148,23 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : - getUnionType(types, 2 /* Subtype */); + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* TypeFlags.Nullable */) : + getUnionType(types, 2 /* UnionReduction.Subtype */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; + } + function isArrayOrTupleType(type) { + return isArrayType(type) || isTupleType(type); } function isMutableArrayOrTuple(type) { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; @@ -66920,22 +67175,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -66950,7 +67205,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -66977,44 +67232,44 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getBaseTypeOfLiteralType) : type; } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67045,10 +67300,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -67069,7 +67324,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -67077,7 +67332,7 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; @@ -67095,31 +67350,31 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 : - type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 : - type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 : - type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 : - type.flags & 117724 /* PossiblyFalsy */; + return type.flags & 1048576 /* TypeFlags.Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value === "" ? 128 /* TypeFlags.StringLiteral */ : 0 : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? type.value === 0 ? 256 /* TypeFlags.NumberLiteral */ : 0 : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* TypeFlags.BigIntLiteral */ : 0 : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* TypeFlags.BooleanLiteral */ : 0 : + type.flags & 117724 /* TypeFlags.PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* TypeFlags.DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* TypeFlags.DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -67128,24 +67383,24 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' // that isn't eliminated by a NonNullable instantiation. - var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + var reducedType = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? @@ -67173,10 +67428,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -67199,23 +67454,23 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -67245,7 +67500,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -67256,7 +67511,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -67286,7 +67541,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -67298,7 +67553,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -67314,7 +67569,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -67333,36 +67588,36 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -67385,8 +67640,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -67399,7 +67654,7 @@ var ts; } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { @@ -67411,7 +67666,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -67430,17 +67685,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -67451,25 +67706,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -67478,10 +67733,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -67493,7 +67748,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -67596,9 +67851,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -67644,40 +67899,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? false : "quit"; })); } return false; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || - type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -67685,7 +67940,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -67713,7 +67968,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -67730,14 +67985,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -67772,7 +68027,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -67782,9 +68037,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -67802,7 +68057,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -67813,7 +68068,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -67835,12 +68090,12 @@ var ts; sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); } function isValidBigIntString(s) { - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - if (result === 40 /* MinusToken */) { + if (result === 40 /* SyntaxKind.MinusToken */) { result = scanner.scan(); } var flags = scanner.getTokenFlags(); @@ -67849,27 +68104,27 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */); } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || - target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + return !!(target.flags & 8 /* TypeFlags.Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* TypeFlags.BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -67879,7 +68134,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -67961,12 +68216,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -67988,7 +68243,7 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -67997,10 +68252,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68015,21 +68270,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -68037,10 +68292,10 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -68048,12 +68303,12 @@ var ts; // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* InferencePriority.ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -68078,7 +68333,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -68091,11 +68346,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -68103,45 +68358,45 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); contravariant = !contravariant; } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); var oldPriority = priority; - priority |= 4 /* SubstituteSource */; + priority |= 4 /* InferencePriority.SubstituteSource */; inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority priority = oldPriority; } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -68149,17 +68404,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -68172,7 +68427,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -68190,19 +68445,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -68210,7 +68465,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -68238,7 +68493,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -68247,7 +68502,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -68257,7 +68512,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -68271,7 +68526,7 @@ var ts; var typeVariable; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -68281,9 +68536,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -68299,11 +68554,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -68314,7 +68569,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -68348,17 +68603,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -68366,7 +68621,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -68378,17 +68633,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -68407,7 +68662,7 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); @@ -68415,7 +68670,7 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; @@ -68437,7 +68692,7 @@ var ts; } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -68452,7 +68707,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -68460,7 +68715,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); @@ -68475,21 +68730,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -68498,14 +68753,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -68525,8 +68780,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -68546,7 +68801,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -68554,9 +68809,9 @@ var ts; function inferFromSignature(source, target, skipParameters) { if (!skipParameters) { var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -68564,7 +68819,7 @@ var ts; } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -68572,9 +68827,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -68599,34 +68854,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -68643,8 +68898,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -68658,14 +68913,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -68686,7 +68941,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -68756,7 +69011,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -68768,7 +69023,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -68777,7 +69032,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -68785,22 +69040,22 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -68811,44 +69066,44 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -68869,15 +69124,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -68916,12 +69171,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -68951,7 +69206,7 @@ var ts; var map = new ts.Map(); var count = 0; var _loop_23 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -68987,15 +69242,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -69019,7 +69274,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -69036,7 +69291,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -69050,7 +69305,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69066,11 +69321,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { + if (assignedType.flags & 131072 /* TypeFlags.Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { + if (assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType)) { reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types } // Our crude heuristic produces an invalid result in some cases: see GH#26130. @@ -69093,93 +69348,93 @@ var ts; function getTypeFacts(type, ignoreObjects) { if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; - if (flags & 4 /* String */) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & 4 /* TypeFlags.String */) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & 128 /* StringLiteral */) { + if (flags & 128 /* TypeFlags.StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { if (ignoreObjects) { - return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection. + return 16768959 /* TypeFacts.AndFactsMask */; // This is the identity element for computing type facts of intersection. } - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 16318463 /* TypeFacts.EmptyObjectStrictFacts */ : 16777215 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { - return 9830144 /* UndefinedFacts */; + if (flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { + return 9830144 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 9363232 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 9363232 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 465829888 /* Instantiable */) { + if (flags & 465829888 /* TypeFlags.Instantiable */) { return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : - strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; + strictNullChecks ? 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */)); return getIntersectionTypeFacts(type, ignoreObjects); } - return 16777215 /* All */; + return 16777215 /* TypeFacts.All */; } function getIntersectionTypeFacts(type, ignoreObjects) { // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 16777215 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 16777215 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; var f = getTypeFacts(t, ignoreObjects); oredFacts |= f; andedFacts &= f; } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 16768959 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -69199,7 +69454,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -69210,18 +69465,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -69238,21 +69493,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -69260,7 +69515,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -69278,37 +69533,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -69316,13 +69571,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -69342,7 +69597,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -69355,13 +69610,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -69370,25 +69625,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -69396,45 +69651,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -69445,11 +69700,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -69461,13 +69716,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -69479,14 +69734,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -69501,10 +69756,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -69512,17 +69767,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { var t = types_18[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -69536,16 +69791,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -69554,11 +69809,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -69569,11 +69824,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -69588,16 +69843,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -69615,7 +69870,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -69629,10 +69884,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -69640,7 +69895,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -69650,10 +69905,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -69673,8 +69928,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -69682,7 +69937,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -69690,30 +69945,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -69721,7 +69976,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -69729,7 +69984,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -69740,7 +69995,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -69749,7 +70004,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -69757,24 +70012,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -69784,18 +70039,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -69821,8 +70076,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -69838,7 +70093,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -69847,7 +70102,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -69860,56 +70115,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -69933,7 +70188,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -69945,7 +70200,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -69956,7 +70211,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -69973,14 +70228,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -69988,14 +70243,14 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -70005,15 +70260,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : - predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -70022,15 +70277,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -70039,7 +70294,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -70053,7 +70308,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -70063,7 +70318,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -70078,16 +70333,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -70104,7 +70359,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -70148,7 +70403,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -70174,7 +70429,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -70227,7 +70482,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -70242,7 +70497,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -70288,8 +70543,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -70305,8 +70560,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -70314,16 +70569,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -70332,7 +70587,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -70343,52 +70598,52 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType : - getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return type.flags & 2 /* TypeFlags.Unknown */ && assumeTrue ? nonNullUnknownType : + getTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -70420,35 +70675,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -70481,48 +70736,48 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) { + if (assumeTrue && (type.flags & 2 /* TypeFlags.Unknown */) && (operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */) && (valueType.flags & 65536 /* TypeFlags.Null */)) { return getUnionType([nullType, undefinedType]); } - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; - return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; + return type.flags & 2 /* TypeFlags.Unknown */ && facts & (1048576 /* TypeFacts.NENull */ | 2097152 /* TypeFacts.NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -70534,34 +70789,34 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } - if (type.flags & 1 /* Any */ && literal.text === "function") { + if (type.flags & 1 /* TypeFlags.Any */ && literal.text === "function") { return type; } - if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { + if (assumeTrue && type.flags & 2 /* TypeFlags.Unknown */ && literal.text === "object") { // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null // unknown type, and then narrows that to the non-primitive type. return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeFacts.TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */; var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text); return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -70574,16 +70829,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -70596,20 +70851,20 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { switch (text) { case "function": - return type.flags & 1 /* Any */ ? type : globalFunctionType; + return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType; case "object": - return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; default: return typeofTypesByName.get(text); } @@ -70628,7 +70883,7 @@ var ts; if (isTypeSubtypeOf(candidate, type)) { return candidate; } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(candidate, constraint)) { return getIntersectionType([type, candidate]); @@ -70703,7 +70958,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -70733,8 +70988,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -70745,7 +71000,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -70768,13 +71023,13 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; @@ -70787,9 +71042,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { + if (!(assignableType.flags & 131072 /* TypeFlags.Never */)) { return assignableType; } } @@ -70807,7 +71062,7 @@ var ts; if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -70817,7 +71072,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -70832,8 +71087,8 @@ var ts; return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { @@ -70848,11 +71103,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -70868,20 +71123,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -70890,11 +71145,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -70905,7 +71160,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -70929,9 +71184,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -70941,8 +71196,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -70951,11 +71206,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -70968,18 +71223,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 32768 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -70991,17 +71246,17 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -71010,8 +71265,8 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) : getContextualType(node)); return contextualType && !isGenericType(contextualType); } @@ -71023,10 +71278,10 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); - return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (n) { @@ -71044,9 +71299,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -71089,16 +71344,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { - var links = getNodeLinks(location); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { + var links = getNodeLinks(parent); + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -71132,7 +71387,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -71163,15 +71418,15 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } // We should only mark aliases as referenced if there isn't a local value declaration @@ -71185,32 +71440,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -71222,19 +71477,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -71243,11 +71498,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -71264,17 +71519,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -71282,11 +71537,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -71303,7 +71558,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -71320,11 +71575,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -71339,12 +71594,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -71354,22 +71609,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -71379,7 +71634,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -71387,9 +71642,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -71399,13 +71654,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -71447,36 +71702,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -71511,7 +71766,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -71559,9 +71814,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -71569,31 +71824,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -71605,17 +71860,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -71625,18 +71880,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -71647,14 +71902,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -71662,26 +71917,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -71743,12 +71998,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -71757,8 +72012,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -71778,12 +72033,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -71793,7 +72048,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -71801,23 +72056,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -71825,22 +72080,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -71867,7 +72122,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -71881,7 +72136,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -71909,7 +72164,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -71934,11 +72189,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -71949,10 +72204,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -71985,7 +72240,7 @@ var ts; if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } @@ -71997,8 +72252,8 @@ var ts; var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var use = functionFlags & 2 /* FunctionFlags.Async */ ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); if (!iterationTypes) { return undefined; @@ -72006,7 +72261,7 @@ var ts; contextualReturnType = iterationTypes.returnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72032,7 +72287,7 @@ var ts; if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); } } return undefined; @@ -72051,7 +72306,7 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); var contextualReturnType = getContextualReturnType(functionDecl); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) @@ -72098,11 +72353,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -72111,13 +72366,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -72126,8 +72381,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -72160,8 +72415,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -72171,11 +72426,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (decl.initializer && getTypeOfExpression(binaryExpression.left)); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -72196,7 +72451,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -72210,18 +72465,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -72229,14 +72484,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -72260,7 +72515,7 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { @@ -72273,7 +72528,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -72294,7 +72549,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72329,7 +72584,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -72384,29 +72639,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -72415,24 +72670,24 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. - if (contextFlags && contextFlags & 1 /* Signature */) { + if (contextFlags && contextFlags & 1 /* ContextFlags.Signature */) { return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); } // For other purposes (e.g. determining whether to produce literal types) we only @@ -72441,7 +72696,7 @@ var ts; // literals actually end up widening to 'boolean' (see #48363). if (inferenceContext.returnMapper) { var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -72453,13 +72708,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -72482,7 +72737,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72491,60 +72746,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -72557,7 +72812,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -72566,7 +72821,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -72611,7 +72866,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -72626,7 +72881,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -72727,12 +72982,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -72754,18 +73009,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -72795,16 +73050,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -72833,18 +73088,18 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -72857,14 +73112,14 @@ var ts; var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -72880,27 +73135,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -72914,28 +73169,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -72944,14 +73199,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -72962,17 +73217,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -72988,7 +73243,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -73000,11 +73255,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -73024,9 +73279,9 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -73048,16 +73303,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -73069,29 +73324,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -73106,17 +73361,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -73150,10 +73405,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -73178,11 +73433,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -73214,12 +73469,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -73229,8 +73484,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -73276,7 +73531,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -73300,15 +73555,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -73323,7 +73578,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -73339,6 +73594,7 @@ var ts; } } else { + error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -73349,7 +73605,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -73363,7 +73619,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -73391,7 +73647,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -73401,12 +73657,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -73418,7 +73674,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -73438,7 +73694,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -73457,13 +73713,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -73512,10 +73768,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -73528,7 +73784,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -73543,7 +73799,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -73567,7 +73823,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -73581,10 +73837,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -73597,12 +73853,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -73630,13 +73886,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -73667,10 +73923,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -73704,7 +73960,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -73722,20 +73978,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -73744,7 +74000,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -73769,7 +74025,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -73781,7 +74037,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -73792,10 +74048,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -73818,13 +74074,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -73838,9 +74094,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -73863,7 +74119,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -73871,7 +74127,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -73883,7 +74139,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -73894,12 +74150,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -73926,7 +74182,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -73934,10 +74190,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -73952,10 +74208,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -73965,39 +74221,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */; if (kind) { reportError(node, kind); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -74006,13 +74262,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -74025,7 +74281,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -74049,7 +74305,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -74121,16 +74377,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -74152,8 +74408,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -74169,15 +74425,20 @@ var ts; prop = getPropertyOfType(apparentType, right.escapedText); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined + // here even if `Foo` is not a const enum. + // // The exceptions are: // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. - if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -74185,7 +74446,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -74205,7 +74466,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -74217,7 +74478,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -74236,11 +74497,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -74250,12 +74511,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -74268,12 +74529,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -74286,7 +74547,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; @@ -74304,13 +74565,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -74321,25 +74582,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -74351,7 +74612,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -74376,7 +74637,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -74464,7 +74725,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -74475,7 +74736,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -74483,7 +74744,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -74502,7 +74763,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -74518,7 +74779,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -74549,7 +74810,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -74577,7 +74838,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -74587,16 +74848,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -74606,19 +74867,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -74633,7 +74894,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -74673,13 +74934,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -74696,13 +74957,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -74716,7 +74977,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -74725,7 +74986,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -74737,8 +74998,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -74751,13 +75012,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -74821,16 +75082,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -74838,9 +75099,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -74851,11 +75112,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -74869,7 +75130,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -74893,7 +75154,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -74909,20 +75170,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -74931,12 +75192,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -74944,7 +75205,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -74972,8 +75233,8 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { - var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); + if (node.kind !== 165 /* SyntaxKind.Decorator */) { + var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { @@ -74981,7 +75242,7 @@ var ts; // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. var outerContext = getInferenceContext(node); - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -74995,7 +75256,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of // the source type uses the outer context's return mapper (which excludes inferences made from @@ -75009,7 +75270,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -75022,7 +75283,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -75037,10 +75298,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -75048,7 +75309,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -75058,24 +75319,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -75105,16 +75366,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -75139,7 +75400,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -75147,12 +75408,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -75162,7 +75423,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -75219,7 +75480,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -75237,13 +75498,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -75282,8 +75543,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -75301,17 +75562,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -75325,12 +75586,12 @@ var ts; var _loop_24 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -75352,30 +75613,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -75389,17 +75650,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -75433,7 +75694,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -75475,8 +75736,14 @@ var ts; var parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && ts.isInJSFile(node)) { + return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + var error = hasRestParameter + ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : ts.Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { // between min and max, but with no matching overload @@ -75535,15 +75802,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -75570,7 +75837,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -75598,7 +75866,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -75631,7 +75899,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -75654,7 +75922,7 @@ var ts; var i_1 = 0; var _loop_25 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -75739,7 +76007,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -75762,9 +76030,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -75786,7 +76054,7 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = 0 /* Normal */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -75839,14 +76107,14 @@ var ts; _loop_26(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -75859,7 +76127,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -75896,8 +76164,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -75917,7 +76185,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -75932,7 +76200,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -75941,13 +76209,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -75962,8 +76230,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -75990,7 +76258,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -76006,7 +76274,7 @@ var ts; // use the resolvingSignature singleton to indicate that we deferred processing. This result will be // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -76027,11 +76295,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -76064,7 +76332,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -76073,24 +76341,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -76101,14 +76369,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -76116,7 +76384,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -76124,7 +76392,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -76147,9 +76415,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -76157,16 +76425,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -76175,10 +76443,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { @@ -76228,7 +76496,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -76272,8 +76540,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76283,26 +76551,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -76317,8 +76585,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76329,38 +76597,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -76381,7 +76649,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -76397,16 +76665,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -76429,7 +76697,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -76470,7 +76738,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -76506,16 +76774,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -76538,10 +76806,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -76561,15 +76829,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -76586,11 +76854,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -76603,14 +76871,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -76619,20 +76887,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -76654,7 +76922,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -76669,13 +76937,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -76691,11 +76959,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + newSymbol.aliasTarget = resolveSymbol(symbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -76718,7 +76986,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -76738,40 +77006,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -76779,31 +77047,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -76834,12 +77102,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -76864,7 +77132,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -76872,12 +77140,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -76886,10 +77154,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -76905,19 +77173,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -76930,7 +77198,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -76940,16 +77208,16 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -76982,7 +77250,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77014,7 +77282,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77064,11 +77332,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -77092,14 +77360,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -77107,7 +77375,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -77117,7 +77385,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -77147,7 +77415,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -77167,7 +77435,7 @@ var ts; } } var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { // The contextual signature has a generic rest parameter. We first instantiate the contextual // signature (without fixing type parameters) and assign types to contextually typed parameters. var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); @@ -77211,7 +77479,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -77231,7 +77499,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -77250,7 +77518,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -77298,8 +77566,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -77311,14 +77579,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -77333,36 +77601,36 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { @@ -77371,9 +77639,9 @@ var ts; contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -77387,7 +77655,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -77430,13 +77698,13 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { @@ -77450,7 +77718,7 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -77462,14 +77730,14 @@ var ts; * whether the active clause contains a default clause. */ function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; // When in the default we only collect inequality facts // because default is 'in theory' a set of infinite // equalities. if (hasDefault) { // Value is not equal to any types after the active clause. for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -77479,7 +77747,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -77487,7 +77755,7 @@ var ts; else { // Add equalities for all types in the active clause. for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeFacts.TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -77502,17 +77770,17 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); var type_6 = getBaseConstraintOfType(operandType) || operandType; // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types. - if (type_6.flags & 3 /* AnyOrUnknown */) { - return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */; + if (type_6.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_1) === 556800 /* TypeFacts.AllTypeofNE */; } - return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* TypeFlags.Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -77536,15 +77804,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -77565,11 +77833,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -77590,17 +77858,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -77629,13 +77897,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -77646,9 +77914,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -77656,7 +77924,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -77665,21 +77933,21 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); } var instantiatedContextualSignature = inferenceContext ? @@ -77702,7 +77970,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -77715,7 +77983,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -77727,7 +77995,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -77785,27 +78053,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -77826,11 +78094,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -77838,12 +78106,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -77872,8 +78140,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -77891,21 +78159,36 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = void 0; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -77915,7 +78198,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -77931,7 +78214,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -77942,16 +78225,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -77959,28 +78242,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -78003,8 +78286,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -78024,7 +78307,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var t = types_21[_i]; @@ -78039,30 +78322,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -78074,7 +78357,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -78088,8 +78371,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -78102,8 +78385,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -78128,9 +78411,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -78150,7 +78433,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -78161,17 +78444,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -78193,18 +78476,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -78213,15 +78496,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -78232,7 +78515,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -78248,14 +78531,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* TypeFlags.Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -78264,31 +78547,31 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -78303,59 +78586,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -78386,9 +78669,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -78405,8 +78688,8 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var parent = ts.walkUpParenthesizedExpressions(node.parent); checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } @@ -78466,11 +78749,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -78479,11 +78762,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -78495,28 +78778,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -78525,8 +78808,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -78537,21 +78820,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -78567,26 +78850,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -78604,21 +78887,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -78627,56 +78910,56 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -78686,7 +78969,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -78704,16 +78987,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -78723,12 +79006,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -78738,15 +79021,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -78765,7 +79048,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -78779,13 +79062,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -78828,12 +79111,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -78859,20 +79142,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -78889,15 +79172,15 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { @@ -78911,7 +79194,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -78924,7 +79207,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -78937,7 +79220,7 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); @@ -78946,11 +79229,11 @@ var ts; return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -78962,7 +79245,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -78971,7 +79254,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -78984,7 +79267,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -79004,17 +79287,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -79024,9 +79307,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -79035,7 +79318,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -79050,28 +79333,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -79092,7 +79375,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -79103,23 +79386,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -79167,11 +79450,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -79201,7 +79484,7 @@ var ts; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -79226,7 +79509,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -79259,7 +79542,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -79271,7 +79554,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -79286,7 +79569,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -79296,8 +79579,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -79317,7 +79600,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -79328,7 +79611,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -79346,18 +79629,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -79375,113 +79658,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -79506,19 +79789,28 @@ var ts; if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) { + checkNodeDeferred(node); + addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); + } + function checkTypeParameterDeferred(node) { + if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) { + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); var modifiers = getVarianceModifiers(typeParameter); - if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + if (modifiers) { var symbol = getSymbolOfNode(node.parent); - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); - var saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { + error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubType : markerSuperType); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperType : markerSubType); + var saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); } function checkParameter(node) { // Grammar checking @@ -79528,11 +79820,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -79543,13 +79835,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -79573,7 +79865,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -79607,13 +79899,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -79627,11 +79919,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -79640,29 +79932,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -79678,17 +79970,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -79700,18 +79992,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -79723,11 +80015,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -79738,24 +80030,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -79765,19 +80057,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -79826,15 +80118,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -79851,7 +80143,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -79899,7 +80191,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -79916,7 +80208,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -79926,9 +80218,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -79936,8 +80228,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -79969,7 +80261,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -79990,9 +80282,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -80008,7 +80300,7 @@ var ts; superCallStatement = statement; break; } - if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -80031,7 +80323,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -80049,9 +80341,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -80059,25 +80351,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -80089,7 +80381,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -80121,15 +80413,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -80145,10 +80437,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -80187,29 +80479,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -80229,15 +80521,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -80245,14 +80537,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -80301,7 +80593,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -80311,7 +80603,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -80338,8 +80630,8 @@ var ts; if (node.assertions) { var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -80349,31 +80641,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -80398,16 +80690,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -80424,8 +80716,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -80434,7 +80726,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -80463,7 +80755,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -80488,7 +80780,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -80504,8 +80796,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -80516,10 +80808,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -80563,13 +80855,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -80579,7 +80871,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -80619,15 +80911,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -80660,56 +80952,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -80745,32 +81037,32 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -80790,16 +81082,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -80809,7 +81101,7 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } @@ -80833,7 +81125,7 @@ var ts; var baseConstraint = getBaseConstraintOfType(type); // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { + if (!baseConstraint || (baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { // Nothing to do if `Awaited` doesn't exist var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); if (awaitedSymbol) { @@ -80879,7 +81171,7 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); } @@ -80996,7 +81288,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -81019,10 +81311,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -81042,7 +81334,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -81055,26 +81347,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -81096,9 +81388,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -81133,15 +81425,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -81150,13 +81442,13 @@ var ts; var commonEntityName; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -81201,15 +81493,15 @@ var ts; error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } var firstDecorator = node.decorators[0]; - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -81218,23 +81510,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -81324,9 +81616,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -81340,7 +81632,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -81356,7 +81648,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -81366,7 +81658,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -81384,7 +81676,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -81412,42 +81704,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -81458,41 +81750,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -81503,7 +81795,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -81520,7 +81812,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -81532,17 +81824,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -81579,7 +81871,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -81610,7 +81902,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -81626,10 +81918,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -81642,9 +81934,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -81663,38 +81955,38 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -81711,7 +82003,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -81729,17 +82021,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -81759,8 +82051,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -81774,8 +82066,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -81789,53 +82081,53 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -81846,7 +82138,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -81854,13 +82146,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -81878,7 +82170,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -81910,35 +82202,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -81969,23 +82261,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } if (ts.isBindingElement(node)) { - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -81995,15 +82287,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -82014,7 +82306,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -82031,7 +82323,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -82042,7 +82334,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -82056,7 +82348,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -82072,7 +82364,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (node.initializer) { @@ -82082,10 +82374,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -82093,7 +82385,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -82103,24 +82395,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -82146,7 +82438,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -82155,13 +82447,13 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) @@ -82175,7 +82467,7 @@ var ts; // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -82215,7 +82507,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -82239,7 +82531,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -82269,7 +82561,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -82280,12 +82572,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -82310,29 +82602,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -82364,7 +82656,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -82378,7 +82670,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -82391,7 +82683,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -82408,7 +82700,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -82423,14 +82715,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -82439,10 +82731,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -82459,22 +82751,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -82482,7 +82774,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -82494,7 +82786,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -82503,12 +82795,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -82516,9 +82808,9 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { - return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; @@ -82565,9 +82857,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -82637,17 +82929,17 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } return undefined; } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; @@ -82657,7 +82949,7 @@ var ts; var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; @@ -82696,20 +82988,20 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? + return use & 8 /* IterationUse.ForOfFlag */ ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { // for a sync iterable in an async context, only use the cached types if they are valid. if (iterationTypes !== noIterationTypes) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); @@ -82720,16 +83012,16 @@ var ts; } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : noIterationTypes); @@ -82795,7 +83087,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -82810,11 +83102,11 @@ var ts; function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } @@ -82894,13 +83186,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -82955,15 +83247,15 @@ var ts; if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" @@ -83069,7 +83361,7 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); @@ -83081,15 +83373,15 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync) || errorType : isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -83109,21 +83401,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -83134,7 +83426,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -83142,7 +83434,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -83163,7 +83455,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -83172,7 +83464,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -83209,7 +83501,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -83241,8 +83533,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -83254,7 +83546,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -83274,8 +83566,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -83304,9 +83596,9 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; var _loop_28 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared @@ -83326,7 +83618,7 @@ var ts; function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; var _loop_29 = function (info) { if (info === checkInfo) @@ -83367,7 +83659,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -83446,9 +83738,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -83535,7 +83827,7 @@ var ts; if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -83556,15 +83848,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -83596,18 +83888,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -83642,7 +83934,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -83692,7 +83984,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -83706,7 +83998,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -83725,12 +84017,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -83743,13 +84035,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -83760,9 +84052,9 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible @@ -83794,10 +84086,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -83813,7 +84105,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -83825,7 +84117,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -83833,11 +84125,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -83860,7 +84152,7 @@ var ts; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -83879,7 +84171,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -83893,7 +84185,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -83904,24 +84196,24 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { // either base or derived property is private - not override, skip it continue; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */ + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment continue; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -83929,12 +84221,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -83951,16 +84243,16 @@ var ts; continue; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { // method is overridden with method or property -- correct case continue; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -84026,20 +84318,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -84049,7 +84341,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -84064,7 +84356,7 @@ var ts; ts.setParent(reference, staticBlock); reference.flowNode = staticBlock.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) { + if (!(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */)) { return true; } } @@ -84079,7 +84371,7 @@ var ts; ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 32768 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -84092,7 +84384,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -84125,7 +84417,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -84137,8 +84429,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -84163,7 +84455,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -84180,7 +84472,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -84188,20 +84480,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -84211,60 +84503,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -84300,9 +84592,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -84336,7 +84628,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -84365,9 +84657,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -84398,7 +84690,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -84411,7 +84703,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -84421,7 +84713,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -84437,10 +84729,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -84450,7 +84742,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -84482,23 +84774,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -84509,12 +84801,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -84524,7 +84816,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -84535,20 +84827,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -84562,9 +84854,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -84605,39 +84897,39 @@ var ts; // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -84662,15 +84954,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -84696,11 +84988,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -84709,8 +85001,11 @@ var ts; var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration); var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!ts.isNightly()) { + grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -84743,11 +85038,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -84769,20 +85064,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -84791,7 +85086,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -84806,8 +85101,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -84815,10 +85110,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -84838,12 +85133,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -84853,7 +85148,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -84863,7 +85158,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -84911,15 +85206,15 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -84929,7 +85224,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -84941,8 +85236,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -84959,14 +85254,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -84982,10 +85277,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -85020,11 +85315,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -85070,177 +85365,177 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -85321,7 +85616,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -85333,38 +85628,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 163 /* SyntaxKind.TypeParameter */: + checkTypeParameterDeferred(node); + break; + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -85372,7 +85670,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -85384,9 +85682,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -85398,7 +85696,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -85418,13 +85716,13 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -85448,7 +85746,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -85518,14 +85816,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -85533,17 +85831,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -85551,17 +85849,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -85605,7 +85903,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -85613,25 +85911,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -85639,16 +85937,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -85676,13 +85974,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -85693,12 +85991,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -85708,7 +86006,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -85718,7 +86016,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -85728,17 +86026,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -85754,28 +86052,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -85786,13 +86084,13 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name)); if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { @@ -85804,16 +86102,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -85825,12 +86123,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -85845,7 +86143,7 @@ var ts; function resolveJSDocMemberName(name, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -85857,18 +86155,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -85882,12 +86180,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -85895,27 +86193,32 @@ var ts; return propertyDeclaration; } } - else if (ts.isMetaProperty(parent)) { - var parentType = getTypeOfNode(parent); - var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === 103 /* NewKeyword */) { + else if (ts.isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { + // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } + // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but + // we have a fake expression type made for other reasons already, whose transient `meta` + // member should more exactly be the kind of (declarationless) symbol we want. + // (See #44364 and #45031 for relevant implementation PRs) + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { + return getGlobalImportMetaExpressionType().members.get("meta"); + } + // no other meta properties are valid syntax, thus no others should have symbols + return undefined; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -85927,25 +86230,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -85954,7 +86257,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -85962,19 +86265,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -85984,14 +86287,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -86000,17 +86303,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -86041,7 +86344,7 @@ var ts; if (ts.isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { var symbol = getSymbolAtLocation(node); @@ -86051,7 +86354,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -86072,23 +86375,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -86098,7 +86401,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -86131,14 +86434,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -86148,8 +86451,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -86168,18 +86471,18 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] - : ts.singleElementArray(tryGetAliasTarget(symbol)); + : ts.singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol) { + function tryGetTarget(symbol) { var target; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -86218,13 +86521,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -86242,19 +86545,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -86277,7 +86580,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -86286,20 +86589,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -86315,9 +86618,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -86358,20 +86661,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -86379,7 +86682,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -86396,7 +86699,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -86409,9 +86712,9 @@ var ts; if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } - var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -86449,18 +86752,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); - } - function isOptionalUninitializedParameter(parameter) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86468,10 +86766,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86494,19 +86792,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -86516,7 +86814,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -86532,14 +86830,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -86558,28 +86856,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -86595,37 +86893,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -86644,7 +86942,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -86665,7 +86963,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -86773,18 +87071,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -86800,7 +87098,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -86837,7 +87135,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -86848,9 +87146,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -86897,7 +87195,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -86925,12 +87223,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -87001,7 +87299,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -87063,28 +87361,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -87098,29 +87396,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -87139,14 +87437,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -87160,69 +87458,69 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -87234,186 +87532,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ && - node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -87431,41 +87728,41 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.fail(); } @@ -87476,10 +87773,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -87508,7 +87805,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -87533,7 +87830,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -87568,7 +87865,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -87604,7 +87901,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -87633,7 +87930,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -87650,6 +87947,9 @@ var ts; return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { + if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } function checkGrammarClassDeclarationHeritageClauses(node) { @@ -87658,7 +87958,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -87671,7 +87971,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -87687,14 +87987,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -87705,21 +88005,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -87737,7 +88037,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -87748,23 +88048,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */) { + if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -87779,25 +88079,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -87812,14 +88112,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -87839,7 +88139,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -87849,7 +88149,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -87884,16 +88184,32 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -87902,8 +88218,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -87914,12 +88230,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -87934,20 +88250,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -87957,22 +88273,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -87980,11 +88296,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -88006,17 +88322,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -88026,26 +88342,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -88053,9 +88369,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -88068,10 +88384,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -88089,7 +88405,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -88097,17 +88413,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -88118,11 +88434,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -88130,8 +88446,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -88146,13 +88462,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -88176,18 +88492,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -88195,7 +88511,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -88212,8 +88528,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -88225,7 +88541,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88234,7 +88550,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -88247,7 +88563,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -88264,8 +88580,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -88292,15 +88608,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -88318,12 +88634,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -88381,7 +88697,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -88391,11 +88707,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -88411,11 +88727,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88437,14 +88753,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -88452,7 +88768,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -88461,10 +88777,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -88475,7 +88791,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -88492,19 +88808,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -88517,7 +88833,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -88538,7 +88854,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -88572,7 +88888,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -88580,7 +88896,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -88588,10 +88904,10 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } var nodeArguments = node.arguments; if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) { @@ -88599,7 +88915,7 @@ var ts; checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { var assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } if (nodeArguments.length === 0 || nodeArguments.length > 2) { @@ -88615,14 +88931,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -88631,35 +88947,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -88671,9 +88987,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -88681,7 +88997,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -88703,14 +89019,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -88730,17 +89046,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -88854,7 +89170,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -88862,11 +89178,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -88913,8 +89229,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -88960,446 +89276,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -89624,7 +89940,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -89634,7 +89950,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -89777,14 +90093,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -89861,8 +90177,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -89912,19 +90228,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -89992,7 +90308,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -90085,12 +90401,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -90141,7 +90457,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -90154,13 +90470,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -90191,23 +90507,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90225,9 +90541,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90308,7 +90624,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -90323,27 +90639,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -90405,7 +90721,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -90690,9 +91006,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -90733,14 +91049,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -90755,10 +91071,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -90961,7 +91277,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -91017,8 +91333,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -91044,14 +91360,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -91102,17 +91418,17 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -91123,7 +91439,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -91146,7 +91462,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -91166,10 +91482,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -91182,7 +91498,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -91190,13 +91506,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -91216,15 +91532,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -91244,30 +91560,30 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -91278,80 +91594,80 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. // falls through - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.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 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91361,7 +91677,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91371,35 +91687,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -91409,40 +91725,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -91456,28 +91772,28 @@ var ts; return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -91486,16 +91802,16 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return ts.visitEachChild(node, visitor, context); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); - var classStatement = facts & 2 /* HasConstructorDecorators */ + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var classStatement = facts & 2 /* ClassFacts.HasConstructorDecorators */ ? createClassDeclarationHeadWithDecorators(node, name) : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; @@ -91503,7 +91819,7 @@ var ts; addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -91515,20 +91831,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -91544,21 +91860,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -91574,7 +91890,7 @@ var ts; // ${members} // } // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : undefined; var classDeclaration = factory.createClassDeclaration( @@ -91583,8 +91899,8 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); @@ -91685,7 +92001,7 @@ var ts; var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -91703,7 +92019,7 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); @@ -91836,12 +92152,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -91992,9 +92308,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -92004,7 +92320,7 @@ var ts; : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); ts.setTextRange(helper, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); return helper; } /** @@ -92032,12 +92348,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); return expression; } @@ -92063,7 +92379,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -92100,13 +92416,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); @@ -92122,10 +92438,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -92135,7 +92451,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -92146,12 +92462,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -92168,15 +92484,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -92213,7 +92529,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -92258,83 +92574,83 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return factory.createVoidZero(); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return serializeTypeNode(node.type); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return factory.createIdentifier("Array"); - case 177 /* TypePredicate */: - case 133 /* BooleanKeyword */: + case 177 /* SyntaxKind.TypePredicate */: + case 133 /* SyntaxKind.BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: switch (node.literal.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: - case 8 /* NumericLiteral */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 8 /* SyntaxKind.NumericLiteral */: return factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 151 /* SymbolKeyword */: - return languageVersion < 2 /* ES2015 */ + case 151 /* SyntaxKind.SymbolKeyword */: + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return serializeTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -92347,13 +92663,13 @@ var ts; var serializedUnion; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -92413,7 +92729,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES2015 */ + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -92435,12 +92751,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -92456,14 +92772,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -92491,7 +92807,7 @@ var ts; * available. */ function getGlobalBigIntNameWithFallback() { - return languageVersion < 99 /* ESNext */ + return languageVersion < 99 /* ScriptTarget.ESNext */ ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), /*questionToken*/ undefined, factory.createIdentifier("BigInt"), /*colonToken*/ undefined, factory.createIdentifier("Object")) @@ -92554,7 +92870,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -92582,7 +92898,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { return undefined; } var updated = factory.updatePropertyDeclaration(node, @@ -92613,11 +92929,11 @@ var ts; } var statements = []; resumeLexicalEnvironment(); - var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); + var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); } // Transform parameters into property assignments. Transforms this: // @@ -92636,12 +92952,12 @@ var ts; if (superStatementIndex >= 0) { ts.addRange(statements, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor + // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = ts.addRange(parameterPropertyAssignments, statements); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - // Add remaining statements from the body, skipping the super() call if it was found - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1)); + // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -92661,10 +92977,10 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node) { @@ -92691,7 +93007,7 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { @@ -92767,7 +93083,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -92787,7 +93103,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -92805,7 +93121,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -92882,7 +93198,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -92890,7 +93206,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -92898,7 +93214,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -92964,7 +93280,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93052,12 +93368,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93082,7 +93398,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93092,7 +93408,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93113,7 +93429,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93121,7 +93437,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93129,7 +93445,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93182,7 +93498,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93229,13 +93545,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93258,8 +93574,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*decorators*/ undefined, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) @@ -93283,14 +93599,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93331,8 +93647,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93392,7 +93708,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -93405,7 +93721,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -93426,7 +93742,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -93434,7 +93750,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -93443,7 +93759,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -93452,7 +93768,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Creates a statement for the provided expression. This is used in calls to `map`. @@ -93497,7 +93813,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -93514,37 +93830,37 @@ var ts; : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* TypeScriptSubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -93559,11 +93875,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -93577,7 +93893,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -93586,7 +93902,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -93603,11 +93919,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -93618,8 +93934,8 @@ var ts; || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -93645,9 +93961,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -93673,7 +93989,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -93736,13 +94052,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -93768,7 +94084,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -93776,50 +94092,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 8388608 /* ContainsClassFields */) { + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 8388608 /* ContainsClassFields */ || - node.transformFlags & 33554432 /* ContainsLexicalSuper */ && + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -93838,17 +94154,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -93878,7 +94194,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -93894,19 +94210,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -93955,10 +94271,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94020,11 +94336,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94043,7 +94359,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94062,7 +94378,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94076,7 +94392,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var info = void 0; if (info = accessPrivateIdentifier(node.operand.name)) { @@ -94085,7 +94401,7 @@ var ts; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94108,7 +94424,7 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { var operand = visitInvalidSuperProperty(node.operand); return ts.isPrefixUnaryExpression(node) ? factory.updatePrefixUnaryExpression(node, operand) : @@ -94224,7 +94540,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94251,7 +94567,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94293,7 +94609,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94308,12 +94624,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94353,28 +94669,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94382,8 +94698,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94396,19 +94712,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -94437,7 +94753,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94447,19 +94763,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -94488,12 +94804,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -94548,13 +94864,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -94587,7 +94903,7 @@ var ts; } resumeLexicalEnvironment(); var needsSyntheticConstructor = !constructor && isDerivedClass; - var indexOfFirstStatementAfterSuper = 0; + var indexOfFirstStatementAfterSuperAndPrologue = 0; var prologueStatementCount = 0; var superStatementIndex = -1; var statements = []; @@ -94596,8 +94912,11 @@ var ts; superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; } } if (needsSyntheticConstructor) { @@ -94633,22 +94952,20 @@ var ts; } } if (parameterPropertyDeclarationCount > 0) { - var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); // If there was a super() call found, add parameter properties immediately after it if (superStatementIndex >= 0) { ts.addRange(statements, parameterProperties); } - // If a synthetic super() call was added, add them just after it - else if (needsSyntheticConstructor) { - statements = __spreadArray(__spreadArray([ - statements[0] - ], parameterProperties, true), statements.slice(1), true); - } - // Since there wasn't a super() call, add them to the top of the constructor else { - statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true); + // Add add parameter properties to the top of the constructor after the prologue + var superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) + superAndPrologueStatementCount++; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true); } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -94658,7 +94975,7 @@ var ts; addPropertyOrClassStaticBlockStatements(statements, properties, receiver); // Add existing statements after the initial prologues and super call if (constructor) { - ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), @@ -94743,7 +95060,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -94762,7 +95079,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -94782,7 +95099,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -94801,32 +95118,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -94865,13 +95182,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -94881,10 +95198,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -94894,7 +95211,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -94915,24 +95232,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -94945,8 +95262,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -94979,7 +95296,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -94999,7 +95316,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95032,7 +95349,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95042,7 +95359,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95051,12 +95368,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95067,12 +95384,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95088,7 +95405,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95100,7 +95417,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95111,12 +95428,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95127,12 +95444,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95149,9 +95466,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95193,9 +95510,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95209,7 +95526,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95249,7 +95566,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95368,8 +95685,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -95381,10 +95698,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -95400,39 +95717,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -95440,27 +95757,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -95543,7 +95860,7 @@ var ts; /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95559,7 +95876,7 @@ var ts; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95574,7 +95891,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95589,7 +95906,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95610,7 +95927,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -95664,9 +95981,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -95692,7 +96009,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -95705,10 +96022,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -95752,21 +96069,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -95779,8 +96096,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -95807,30 +96124,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -95850,19 +96167,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -95872,7 +96189,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -95882,7 +96199,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -95897,20 +96214,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -95980,7 +96297,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -96012,7 +96329,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -96034,88 +96351,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -96129,15 +96446,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -96149,7 +96466,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -96158,7 +96475,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -96169,7 +96486,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -96192,7 +96509,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -96219,9 +96536,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -96242,10 +96559,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -96273,10 +96590,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -96288,7 +96605,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -96314,8 +96631,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -96332,8 +96649,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -96361,7 +96678,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -96381,10 +96698,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -96403,18 +96720,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -96422,15 +96739,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -96446,7 +96763,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -96464,7 +96781,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -96510,13 +96827,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateMethodDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96529,13 +96846,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateFunctionDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96559,13 +96876,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96582,13 +96899,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -96599,10 +96916,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -96641,11 +96958,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96654,7 +96971,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96670,32 +96987,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96703,21 +97020,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -96730,8 +97047,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96758,30 +97075,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96801,14 +97118,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -96833,11 +97150,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -96865,29 +97182,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -96929,7 +97246,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -96952,10 +97269,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -96964,7 +97281,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -96974,8 +97291,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -96985,17 +97302,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -97012,7 +97329,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -97046,11 +97363,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -97100,7 +97417,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -97124,12 +97441,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -97155,7 +97472,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -97177,7 +97494,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -97194,7 +97511,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -97210,7 +97527,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -97219,13 +97536,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97233,15 +97550,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -97310,7 +97627,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -97375,7 +97692,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -97415,14 +97732,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - else if (node.kind === 10 /* StringLiteral */) { + else if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 288 /* JsxExpression */) { + else if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -97516,7 +97833,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -97819,11 +98136,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97831,9 +98148,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98023,7 +98340,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -98033,7 +98350,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -98044,15 +98361,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -98067,11 +98384,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -98083,9 +98400,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -98093,115 +98410,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -98212,14 +98529,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -98227,17 +98544,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -98253,11 +98570,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -98284,30 +98601,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -98316,15 +98633,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -98357,18 +98674,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -98425,25 +98742,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -98461,19 +98778,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98499,7 +98816,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -98510,10 +98827,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -98547,7 +98864,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98562,7 +98879,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -98606,7 +98923,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -98616,7 +98933,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -98639,7 +98956,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -98678,7 +98995,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -98699,7 +99016,7 @@ var ts; // ``` insertCaptureThisForNodeIfNeeded(prologue, constructor); } - var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), + var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), /*location*/ constructor.body.statements), /*multiLine*/ true); ts.setTextRange(body, constructor.body); @@ -98728,11 +99045,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -98740,7 +99057,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -98749,10 +99066,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -98841,11 +99158,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -98863,11 +99180,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -98898,10 +99215,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -98911,7 +99228,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -98923,13 +99240,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -98942,7 +99259,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -98956,7 +99273,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -98964,38 +99281,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -99003,11 +99320,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -99026,21 +99343,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -99079,7 +99396,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -99087,7 +99404,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -99101,7 +99418,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -99117,20 +99434,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -99138,7 +99455,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -99161,12 +99478,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -99175,9 +99492,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -99187,17 +99504,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -99212,13 +99529,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, @@ -99236,14 +99553,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -99286,7 +99603,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -99305,7 +99622,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -99326,10 +99643,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -99339,11 +99656,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99374,9 +99691,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -99404,12 +99721,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -99418,10 +99735,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -99438,7 +99755,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99447,11 +99764,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -99460,7 +99777,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 262144 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -99526,18 +99843,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -99564,16 +99881,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -99593,50 +99910,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -99684,7 +100001,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -99716,18 +100033,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -99743,33 +100060,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -99784,9 +100101,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 524288 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 524288 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -99799,7 +100116,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -99811,7 +100128,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -99827,7 +100144,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -99838,7 +100155,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -99858,7 +100175,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -99902,11 +100219,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -99931,11 +100248,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -99944,7 +100261,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -100057,15 +100374,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -100091,12 +100408,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -100158,7 +100475,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -100167,17 +100484,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -100197,18 +100514,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -100221,7 +100538,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -100230,27 +100547,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -100258,7 +100575,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -100317,19 +100634,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -100351,20 +100668,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -100419,14 +100736,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -100435,7 +100752,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -100454,7 +100771,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -100467,17 +100784,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -100520,11 +100837,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -100597,7 +100914,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -100654,15 +100971,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -100676,7 +100993,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -100688,12 +101005,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -100782,13 +101099,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -100804,12 +101121,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -100817,7 +101134,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -100847,7 +101164,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -100882,15 +101199,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -100902,13 +101219,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -100918,9 +101235,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -100928,16 +101245,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -100948,7 +101265,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -100962,7 +101279,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -100978,10 +101295,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -100994,9 +101311,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -101007,7 +101324,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -101044,9 +101361,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -101063,19 +101380,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -101098,18 +101415,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -101128,9 +101445,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -101190,7 +101507,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -101370,11 +101687,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -101428,7 +101745,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -101451,7 +101768,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -101465,13 +101782,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -101484,30 +101801,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -101522,23 +101839,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -101551,9 +101868,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -101712,13 +102029,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101743,9 +102060,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -101761,7 +102078,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -101773,7 +102090,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -101805,7 +102122,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -101839,13 +102156,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -101862,12 +102179,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -101912,7 +102229,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -101978,7 +102295,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -102167,35 +102484,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -102625,7 +102942,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -102638,7 +102955,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -102770,7 +103087,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -102783,7 +103100,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -102814,7 +103131,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -102860,7 +103177,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -102874,7 +103191,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -102903,7 +103220,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -102913,7 +103230,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -102925,8 +103242,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -102939,7 +103256,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -102952,18 +103269,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -102973,24 +103290,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -102998,7 +103315,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -103008,7 +103325,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -103025,7 +103342,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -103037,7 +103354,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103051,7 +103368,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -103064,7 +103381,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -103074,7 +103391,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103083,7 +103400,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -103092,14 +103409,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -103111,8 +103428,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -103120,7 +103437,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -103128,7 +103445,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -103225,7 +103542,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -103237,7 +103554,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -103249,8 +103566,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -103263,7 +103580,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -103272,7 +103589,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -103286,7 +103603,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -103295,7 +103612,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -103306,7 +103623,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -103317,7 +103634,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -103326,7 +103643,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -103335,7 +103652,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -103344,7 +103661,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -103353,13 +103670,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -103403,7 +103720,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -103576,8 +103893,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -103587,18 +103904,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -103622,33 +103939,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -103698,8 +104015,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -103710,9 +104027,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -103723,9 +104040,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -103736,9 +104053,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -103749,8 +104066,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -103761,9 +104078,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -103771,7 +104088,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -103798,12 +104115,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -103819,7 +104136,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 4194304 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -103955,7 +104272,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -104040,7 +104357,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -104109,13 +104426,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -104131,23 +104448,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -104156,30 +104473,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4194304 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -104195,24 +104512,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -104238,7 +104555,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -104264,7 +104581,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -104307,7 +104624,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -104334,7 +104651,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -104370,7 +104687,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -104388,7 +104705,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -104409,7 +104726,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -104429,13 +104746,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -104444,7 +104761,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -104491,7 +104808,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -104505,7 +104822,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -104539,7 +104856,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -104549,11 +104866,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -104594,12 +104911,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -104650,7 +104967,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), @@ -104678,7 +104995,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); @@ -104705,7 +105022,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -104763,7 +105080,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -104778,7 +105095,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -104800,7 +105117,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -104812,7 +105129,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -104855,10 +105172,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -104941,8 +105258,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -104987,7 +105304,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -105000,7 +105317,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -105015,7 +105332,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -105027,7 +105344,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -105054,8 +105371,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -105071,7 +105388,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -105096,7 +105413,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -105131,13 +105448,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -105146,9 +105463,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105157,9 +105474,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105172,16 +105489,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -105270,11 +105587,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -105294,7 +105611,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -105341,7 +105658,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -105463,8 +105780,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 1048576 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -105498,7 +105815,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -105564,7 +105881,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -105588,19 +105905,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -105659,13 +105976,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -105741,7 +106058,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -105794,7 +106111,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -105844,9 +106161,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -105857,7 +106174,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -105909,9 +106226,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -105922,7 +106239,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -105971,10 +106288,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -106068,8 +106385,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -106129,7 +106446,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106141,7 +106458,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -106154,43 +106471,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -106372,30 +106689,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 4194304 /* TransformFlags.ContainsDynamicImport */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -106445,7 +106762,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -106475,7 +106792,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -106491,7 +106808,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -106536,8 +106853,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106553,7 +106870,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -106588,10 +106905,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -106603,7 +106920,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -106638,11 +106955,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -106654,7 +106971,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -106732,7 +107049,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -106775,8 +107092,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -106815,14 +107132,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -106840,7 +107157,7 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause( @@ -106848,16 +107165,16 @@ var ts; /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -106878,12 +107195,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); @@ -106951,7 +107268,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -106960,7 +107277,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -106983,8 +107300,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -107031,7 +107348,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -107086,14 +107403,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107115,14 +107432,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -107146,7 +107463,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -107164,31 +107481,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107211,7 +107528,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -107228,14 +107545,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -107250,36 +107567,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -107291,9 +107608,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -107316,40 +107633,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -107360,61 +107677,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -107431,7 +107748,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -107480,7 +107797,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -107499,13 +107816,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -107564,7 +107881,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -107573,7 +107890,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -107609,7 +107926,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -107680,10 +107997,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -107706,14 +108023,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -107850,11 +108167,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -107862,7 +108179,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -107875,7 +108192,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = factory.updateParameterDeclaration(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -107892,7 +108209,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -107900,19 +108217,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -107920,12 +108237,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -107936,28 +108253,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -107984,7 +108301,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -108021,7 +108338,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -108047,7 +108364,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -108067,7 +108384,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -108085,34 +108402,44 @@ var ts; if (!decl.importClause) { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // The `importClause` visibility corresponds to the default's visibility. var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, - /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } // Named imports (optionally with visible default) var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Augmentation of export depends on import if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, - /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Nothing visible } + function getResolutionModeOverrideForClauseInNightly(assertClause) { + var mode = ts.getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!ts.isNightly()) { + context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } function transformAndReplaceLatePaintedStatements(statements) { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. @@ -108131,7 +108458,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -108189,10 +108516,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -108210,29 +108537,29 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -108242,48 +108569,48 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateSetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { + case 176 /* SyntaxKind.IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -108291,13 +108618,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -108309,22 +108636,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -108347,7 +108674,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -108357,7 +108684,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -108367,17 +108694,17 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -108385,7 +108712,9 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); + preserveJsDoc(statement, input); + ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -108396,22 +108725,26 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { + if (lateMarkedStatements) { + while (ts.orderedRemoveItem(lateMarkedStatements, input)) + ; + } if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -108432,14 +108765,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -108448,7 +108781,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -108467,10 +108800,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -108481,11 +108814,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, @@ -108506,17 +108839,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -108552,7 +108885,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -108562,10 +108895,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -108607,26 +108940,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -108637,10 +108970,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -108651,7 +108984,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -108659,7 +108992,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -108682,7 +109015,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -108730,12 +109063,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 125951 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 125951 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -108755,13 +109088,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -108771,22 +109104,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 125951 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 125951 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -108795,52 +109128,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -108858,7 +109191,7 @@ var ts; return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return ts.transformNodeModule; default: @@ -108897,35 +109230,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -108979,11 +109312,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -108996,7 +109329,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -109026,13 +109359,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -109056,17 +109389,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -109084,15 +109417,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -109102,23 +109435,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -109128,7 +109461,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -109144,26 +109477,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -109175,9 +109508,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -109190,8 +109523,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -109205,19 +109538,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -109226,8 +109559,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -109239,7 +109572,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -109282,8 +109615,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -109292,12 +109625,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -109311,8 +109644,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -109323,14 +109656,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -109345,7 +109678,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -109384,7 +109717,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -109450,7 +109783,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -109458,7 +109791,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -109467,7 +109800,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -109475,7 +109808,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -109489,11 +109822,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -109509,9 +109842,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -109536,20 +109869,20 @@ var ts; addOutput(buildInfoPath); } function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) { - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -109581,7 +109914,7 @@ var ts; /*@internal*/ function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; /*@internal*/ @@ -109618,17 +109951,17 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) continue; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -109637,7 +109970,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -109675,13 +110008,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -109816,7 +110149,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SyntaxKind.SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -109827,7 +110160,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -109839,8 +110172,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -109852,6 +110185,7 @@ var ts; else { printer.writeFile(sourceFile, writer, sourceMapGenerator); } + var sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -109863,7 +110197,8 @@ var ts; if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + sourceMapUrlPos = writer.getTextPos(); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { @@ -109875,13 +110210,13 @@ var ts; writer.writeLine(); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -109912,7 +110247,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -110005,8 +110340,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -110092,7 +110427,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -110144,7 +110479,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -110184,20 +110519,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -110253,11 +110588,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -110292,7 +110627,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -110303,7 +110638,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -110313,7 +110648,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -110340,7 +110675,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -110350,7 +110685,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -110389,7 +110724,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -110397,30 +110732,30 @@ var ts; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); + return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile))); } function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -110429,7 +110764,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -110445,12 +110780,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -110458,17 +110793,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -110478,7 +110813,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -110504,346 +110839,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -110855,101 +111190,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -110957,7 +111292,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -110967,7 +111302,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -110997,7 +111332,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -111039,7 +111374,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -111067,7 +111402,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -111097,9 +111432,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -111118,25 +111453,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -111144,7 +111479,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -111159,7 +111494,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -111196,7 +111531,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -111264,7 +111599,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -111374,8 +111709,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -111388,16 +111723,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -111406,10 +111741,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -111442,7 +111777,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -111456,7 +111791,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -111465,13 +111800,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -111481,7 +111816,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -111489,14 +111824,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -111504,7 +111839,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -111523,7 +111858,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -111539,12 +111874,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -111562,29 +111897,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -111610,7 +111945,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -111623,12 +111958,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111641,17 +111976,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111673,12 +112008,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -111697,22 +112032,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -111737,9 +112072,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -111780,12 +112115,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -111816,11 +112151,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -111831,7 +112166,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -111853,15 +112188,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -111904,10 +112239,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -111928,21 +112263,21 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) - if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -111952,14 +112287,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -111975,45 +112310,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -112022,12 +112357,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -112050,13 +112385,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -112096,40 +112431,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -112138,13 +112473,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -112160,7 +112495,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -112178,7 +112513,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -112215,23 +112550,23 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { return false; } - if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { + if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) { + if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -112246,14 +112581,9 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -112266,11 +112596,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -112285,15 +112615,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -112306,10 +112636,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -112332,13 +112662,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -112360,27 +112690,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112389,12 +112719,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -112405,20 +112735,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112429,37 +112759,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -112469,10 +112799,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -112480,26 +112810,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112511,7 +112841,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -112522,7 +112852,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -112541,7 +112871,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -112554,7 +112884,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -112583,7 +112913,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -112614,17 +112944,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112635,30 +112965,31 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { var emitAsSingleStatement = statements.length === 1 && ( // treat synthesized nodes as located on the same line for emit purposes - ts.nodeIsSynthesized(parentNode) || + !currentSourceFile || + ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -112666,15 +112997,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -112694,7 +113025,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -112711,7 +113042,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -112742,12 +113073,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -112781,13 +113112,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -112806,7 +113137,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -112824,14 +113155,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -112879,16 +113210,14 @@ var ts; function emitSourceFile(node) { writeLine(); var statements = node.statements; - if (emitBodyWithDetachedComments) { - // Emit detached comment if there are no prologue directives or if the first node is synthesized. - // The synthesized node will have no leading comment so some comments may be missed. - var shouldEmitDetachedComment = statements.length === 0 || - !ts.isPrologueDirective(statements[0]) || - ts.nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -112914,21 +113243,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -112936,28 +113265,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { var directive = types_24[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -112968,22 +113297,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -113004,7 +113333,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -113025,7 +113354,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -113118,7 +113447,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 262656 /* Modifiers */); + emitList(node, modifiers, 262656 /* ListFormat.Modifiers */); writeSpace(); } } @@ -113132,7 +113461,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -113162,7 +113491,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -113170,7 +113499,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -113179,19 +113508,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -113212,32 +113541,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -113253,11 +113582,11 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -113266,7 +113595,7 @@ var ts; } return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -113277,28 +113606,28 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } else { ts.Debug.type(children); // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -113309,7 +113638,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -113321,7 +113650,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -113331,14 +113660,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -113361,11 +113690,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (hasTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -113377,11 +113706,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -113390,14 +113719,14 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -113482,7 +113811,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -113532,13 +113861,13 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -113558,11 +113887,11 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild_1.kind === 11 /* JsxText */) { + if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { @@ -113575,18 +113904,18 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); } @@ -113600,7 +113929,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -113609,18 +113938,18 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -113631,7 +113960,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -113660,14 +113989,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -113676,14 +114005,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -113693,7 +114022,7 @@ var ts; if (ts.getStartsOnNewLine(node2)) { return 1; } - if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); } @@ -113703,10 +114032,10 @@ var ts; } function isEmptyBlock(block) { return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -113715,41 +114044,48 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return generateName(node); } - else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { - return ts.idText(node); - } - else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (ts.isStringLiteral(node) && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + var sourceFile = currentSourceFile; // const needed for control flow + var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node); + if (ts.isMemberName(node)) { + if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) { + return ts.idText(node); + } + } + else { + ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary + if (!canUseSourceFile) { + return node.text; + } } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -113760,7 +114096,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -113776,84 +114112,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -113862,12 +114198,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -113886,7 +114222,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -113925,7 +114261,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -113939,7 +114275,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -113949,12 +114285,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -113986,7 +114322,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -114040,48 +114376,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -114097,7 +114433,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -114108,7 +114444,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -114121,7 +114457,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -114129,7 +114465,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -114143,25 +114479,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -114171,7 +114507,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -114180,18 +114516,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -114209,25 +114545,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -114303,7 +114639,7 @@ var ts; return true; } function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); @@ -114316,7 +114652,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -114330,7 +114666,7 @@ var ts; forEachTrailingCommentToEmit(pos, emitTrailingComment); } function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { @@ -114352,15 +114688,19 @@ var ts; exitComment(); } function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); @@ -114393,6 +114733,8 @@ var ts; return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { + if (!currentSourceFile) + return; // get the leading comments from detachedPos var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { @@ -114404,7 +114746,7 @@ var ts; ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -114415,7 +114757,7 @@ var ts; } } function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); @@ -114427,7 +114769,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps function getParsedSourceMap(node) { @@ -114437,7 +114779,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -114455,12 +114797,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -114470,11 +114812,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -114527,17 +114869,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -114568,23 +114910,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -114950,7 +115292,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -114959,11 +115301,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -114973,7 +115315,7 @@ var ts; if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored - if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileOrDirectoryPath)) { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; @@ -114985,9 +115327,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -115020,7 +115362,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -115055,36 +115397,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -115094,16 +115436,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -115315,7 +115657,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -115326,7 +115668,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -115342,7 +115684,11 @@ var ts; return newValue; }; if (originalWriteFile) { - host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) { + host.writeFile = function (fileName, data) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); @@ -115356,7 +115702,7 @@ var ts; sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } // directoryExists @@ -115410,12 +115756,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -115503,9 +115849,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -115519,7 +115865,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -115582,7 +115928,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115688,7 +116034,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115868,11 +116214,11 @@ var ts; */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { - case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; @@ -115922,7 +116268,6 @@ var ts; ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -116028,7 +116373,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -116109,16 +116454,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -116146,7 +116491,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -116155,19 +116500,19 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId }); } ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -116289,14 +116634,15 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, + writeFile: writeFile, }; onProgramCreateComplete(); // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -116308,17 +116654,52 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; + function addResolutionDiagnostics(list) { + if (!list) + return; + for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { + var elem = list_3[_i]; + programDiagnostics.add(elem); + } + } + function pullDiagnosticsFromCache(names, containingFile) { + var _a; + if (!moduleResolutionCache) + return; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + var containingDir = ts.getDirectoryPath(containingFileName); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var n = names_4[_i]; + // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less + var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + var name = typeof n === "string" ? n : n.fileName; + i++; + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + if (ts.isExternalModuleNameRelative(name)) + continue; + var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -116327,7 +116708,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -116337,7 +116718,7 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) + if (redirect || !ts.isDeclarationFileName(file.originalFileName)) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case @@ -116409,7 +116790,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -116564,22 +116945,22 @@ var ts; function tryReuseStructureFromOldProgram() { var _a; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -116587,12 +116968,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -116607,7 +116988,7 @@ var ts; ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; @@ -116616,7 +116997,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -116624,7 +117005,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -116641,9 +117022,9 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } @@ -116651,49 +117032,49 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); @@ -116714,7 +117095,7 @@ var ts; // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -116725,18 +117106,18 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping @@ -116767,7 +117148,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -116786,7 +117167,7 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, getSymlinkCache: getSymlinkCache, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + writeFile: writeFileCallback || writeFile, isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { @@ -116806,9 +117187,12 @@ var ts; getFileIncludeReasons: program.getFileIncludeReasons, }; } + function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -116860,7 +117244,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -116980,7 +117364,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -116988,8 +117372,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -117068,22 +117452,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -117091,65 +117475,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -117158,53 +117542,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 124 /* StaticKeyword */) { + if (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -117217,27 +117601,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -117307,20 +117691,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -117351,7 +117735,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -117373,7 +117757,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -117428,7 +117812,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -117543,7 +117927,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -117728,7 +118112,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -117738,7 +118122,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -117771,13 +118155,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -117816,14 +118200,14 @@ var ts; var fileName = ts.toFileNameLowerCase(ref.fileName); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); var mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { - programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { + programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, }); } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -117882,7 +118266,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -117902,7 +118286,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -117949,7 +118333,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -118010,7 +118394,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -118150,19 +118534,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -118179,7 +118563,7 @@ var ts; } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && - ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -118201,7 +118585,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -118223,7 +118607,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -118237,7 +118621,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -118245,12 +118629,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -118329,7 +118713,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -118568,7 +118952,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -118578,16 +118962,16 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -118688,12 +119072,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -118746,7 +119130,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -118842,17 +119226,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -118871,7 +119255,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -118886,7 +119270,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -118911,13 +119295,9 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - var manyToManyPathMapCount = 0; function createManyToManyPathMap() { function create(forward, reverse, deleted) { - var version = 0; var map = { - id: manyToManyPathMapCount++, - version: function () { return version; }, clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, @@ -118933,30 +119313,29 @@ var ts; } set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); forward.delete(k); - version++; return true; }, set: function (k, vSet) { - var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + deleted === null || deleted === void 0 ? void 0 : deleted.delete(k); var existingVSet = forward.get(k); forward.set(k, vSet); existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(function (v) { if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } return map; }, + clear: function () { + forward.clear(); + reverse.clear(); + deleted === null || deleted === void 0 ? void 0 : deleted.clear(); + } }; return map; } @@ -118971,11 +119350,10 @@ var ts; } set.add(v); } - function deleteFromMultimap(map, k, v, removeEmpty) { - if (removeEmpty === void 0) { removeEmpty = true; } + function deleteFromMultimap(map, k, v) { var set = map.get(k); if (set === null || set === void 0 ? void 0 : set.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -119204,7 +119582,7 @@ var ts; /*forceDtsEmit*/ true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -119254,6 +119632,7 @@ var ts; } } } + BuilderState.updateExportedModules = updateExportedModules; /** * Updates the exported modules from cache into state's exported modules map * This should be called whenever it is safe to commit the state of the builder @@ -119262,20 +119641,6 @@ var ts; var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - var cacheId = exportedModulesMapCache.id; - var cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - // If this is the same cache at the same version as last time this BuilderState - // was updated, there's no need to update again - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } @@ -119524,7 +119889,7 @@ var ts; } else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -119609,7 +119974,8 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash) { + function getNextAffectedFile(state, cancellationToken, computeHash, host) { + var _a; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -119620,7 +119986,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -119632,6 +119998,7 @@ var ts; ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); state.currentAffectedFilesSignatures.clear(); ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); state.affectedFiles = undefined; } // Get next changed file @@ -119661,6 +120028,11 @@ var ts; state.seenAffectedFiles = new ts.Set(); } } + function clearAffectedFilesPendingEmit(state) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } /** * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet */ @@ -119680,49 +120052,48 @@ var ts; } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } + function removeDiagnosticsOfLibraryFiles(state) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var program_1 = ts.Debug.checkDefined(state.program); + var options_2 = program_1.getCompilerOptions(); + ts.forEach(program_1.getSourceFiles(), function (f) { + return program_1.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2, program_1) && + removeSemanticDiagnosticsOf(state, f.resolvedPath); + }); + } + } /** * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.checkDefined(state.program); - var options_2 = program_1.getCompilerOptions(); - ts.forEach(program_1.getSourceFiles(), function (f) { - return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2, program_1) && - removeSemanticDiagnosticsOf(state, f.resolvedPath); - }); - } + removeDiagnosticsOfLibraryFiles(state); // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } - else { - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); - } - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); - } + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) + return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -119733,11 +120104,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, - /* useFileVersionAsSignature */ true); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -119759,16 +120129,41 @@ var ts; var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } + function forEachKeyOfExportedModulesMap(state, filePath, fn) { + // Go through exported modules from cache first + var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); + var result = keys && ts.forEachKey(keys, fn); + if (result) + return result; + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + keys = state.exportedModulesMap.getKeys(filePath); + return keys && ts.forEachKey(keys, function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? + fn(exportedFromPath) : + undefined; + }); + } + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + var _a; + if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) + return false; + // Every file needs to be handled + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + removeDiagnosticsOfLibraryFiles(state); + return true; + } /** - * Iterate on referencing modules that export entities from affected file + * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - var _a, _b; + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; - } if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself @@ -119781,7 +120176,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -119793,56 +120190,38 @@ var ts; var seenFileAndExportsOfFile = new ts.Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + return true; + var references = state.referencedMap.getKeys(exportedFromPath); + return references && ts.forEachKey(references, function (filePath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + }); }); } /** - * Iterate on files referencing referencedPath + * handle dts and semantic diagnostics on file and iterate on anything that exports this file + * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { var _a; - (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { - return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); - }); - } - /** - * fn on file and iterate on anything that exports this file - */ - function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { - var _a, _b, _c; - if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - fn(state, filePath); + if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) + return undefined; + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) - (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file - fn(state, referencingFilePath); - } // Dont add to seen since this is not yet done with the export removal - ); + handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal + state, referencingFilePath, cancellationToken, computeHash, host); + }); + return undefined; } /** * This is called after completing operation on the next affected file. @@ -119931,13 +120310,18 @@ var ts; var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + // If file version is same as signature, dont serialize signature + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // If file info only contains version and signature and both are same we can just write string value.version : - actualSignature !== undefined ? + actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo signature === undefined ? + // If we havent computed signature, use fileInfo as is value : + // Serialize fileInfo with new updated signature { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // Signature of the FileInfo is undefined, serialize it as false { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; @@ -120182,8 +120566,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -120196,7 +120580,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -120213,7 +120597,43 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + } + function getWriteFileUpdatingSignatureCallback(writeFile) { + return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + var _a; + if (ts.isDeclarationFileName(fileName)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; + if (signature === file.version) { + var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { // Update it + if (host.storeFilesChangingSignatureDuringEmit) + (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); + if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { + state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) + ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) + writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else + state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; } /** * Emits the JavaScript and declaration files. @@ -120227,56 +120647,52 @@ var ts; * in that order would be used to write the files */ function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var restorePendingEmitOnHandlingNoEmitSuccess = false; - var savedAffectedFilesPendingEmit; - var savedAffectedFilesPendingEmitKind; - var savedAffectedFilesPendingEmitIndex; - // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors - // This ensures pending files to emit is updated in tsbuildinfo - // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit) - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !ts.outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } + var _a; if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } // Emit only affected files if using builder for emit - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - // Emit and report any errors we ran into. - var sourceMaps = []; - var emitSkipped = false; - var diagnostics = void 0; - var emittedFiles = []; - var affectedEmitResult = void 0; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + // Emit and report any errors we ran into. + var sourceMaps = []; + var emitSkipped = false; + var diagnostics = void 0; + var emittedFiles = []; + var affectedEmitResult = void 0; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped: emitSkipped, + diagnostics: diagnostics || ts.emptyArray, + emittedFiles: emittedFiles, + sourceMaps: sourceMaps + }; + } + // In non Emit builder, clear affected files pending emit + else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) { + ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + // State can clear affected files pending emit if + if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared + // If every file pending emit is pending on only dts emit + || ts.every(state.affectedFilesPendingEmit, function (path, index) { + return index < state.affectedFilesPendingEmitIndex || + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; + })) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped: emitSkipped, - diagnostics: diagnostics || ts.emptyArray, - emittedFiles: emittedFiles, - sourceMaps: sourceMaps - }; } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** * Return the semantic diagnostics for the next affected file or undefined if iteration is complete @@ -120284,7 +120700,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { // Done return undefined; @@ -120296,7 +120712,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -120508,7 +120924,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -120565,7 +120981,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); @@ -120720,8 +121136,8 @@ var ts; !!redirectedReference; var seenNamesInFile = ts.createModeAwareCache(); var i = 0; - for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { - var entry = names_4[_i]; + for (var _i = 0, names_5 = names; _i < names_5.length; _i++) { + var entry = names_5[_i]; var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase(); // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant // they require calculating the mode for a given import from it's position in the resolution table, since a given @@ -120865,7 +121281,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -121042,7 +121458,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -121053,7 +121469,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -121193,7 +121609,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -121261,33 +121677,33 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { var _a; - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { return false; } @@ -121331,14 +121747,14 @@ var ts; if (options === void 0) { options = {}; } var info = getInfo(importingSourceFile.path, host); var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); }); } moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) { if (options === void 0) { options = {}; } var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { @@ -121395,7 +121811,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -121414,7 +121830,7 @@ var ts; var relativeSpecifiers; for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { var modulePath = modulePaths_1[_i]; - var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", @@ -121456,7 +121872,7 @@ var ts; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -121470,10 +121886,10 @@ var ts; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -121507,7 +121923,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -121515,7 +121931,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -121686,11 +122102,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -121731,23 +122147,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -121774,9 +122190,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -121807,7 +122223,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) { + function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) { var path = _a.path, isRedirect = _a.isRedirect; var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { @@ -121821,8 +122237,9 @@ var ts; var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; - var moduleFileNameForExtensionless = void 0; + var moduleFileName = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; @@ -121839,12 +122256,12 @@ var ts; isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) - moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) + moduleFileName = moduleFileToTry; // try with next level of directory packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -121872,7 +122289,7 @@ var ts; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); - if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` @@ -121896,13 +122313,13 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Ending.Minimal */, options), versionPaths.paths); if (fromPaths !== undefined) { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name - var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -121910,24 +122327,21 @@ var ts; } } } - return { moduleFileToTry: moduleFileToTry }; - } - function getExtensionlessFileName(path) { - // We still have a file name - remove the extension - var fullModulePathWithoutExtension = ts.removeFileExtension(path); - // If the file is /index, it can be imported by its directory name - // IFF there is not _also_ a file by the same name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + // No package.json exists; an index.js will still resolve as the package name + var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath }; + } } - return fullModulePathWithoutExtension; + return { moduleFileToTry: moduleFileToTry }; } } function tryGetAnyFileFromPath(host, path) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -121942,18 +122356,24 @@ var ts; return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } - function removeExtensionAndIndexPostFix(fileName, ending, options) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + function removeExtensionAndIndexPostFix(fileName, ending, options, host) { + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: - return ts.removeSuffix(noExtension, "/index"); - case 1 /* Index */: + case 0 /* Ending.Minimal */: + var withoutIndex = ts.removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + // Can't remove index if there's a file by the same name as the directory. + // Probably more callers should pass `host` so we can determine this? + return noExtension; + } + return withoutIndex; + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -121961,28 +122381,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -122064,8 +122484,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -122073,8 +122493,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -122097,7 +122517,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -122130,7 +122550,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -122143,7 +122563,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -122166,7 +122586,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -122193,9 +122613,9 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; @@ -122228,14 +122648,14 @@ var ts; var configFile = program.getCompilerOptions().configFile; if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs)) return undefined; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -122244,7 +122664,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -122368,7 +122788,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -122468,6 +122888,7 @@ var ts; createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -122527,6 +122948,7 @@ var ts; createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } ts.createProgramHost = createProgramHost; @@ -122615,6 +123037,7 @@ var ts; var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -122697,7 +123120,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -122853,10 +123276,10 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -123017,7 +123440,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -123077,7 +123500,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -123118,7 +123541,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -123359,7 +123782,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -123404,9 +123827,6 @@ var ts; function newer(date1, date2) { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); - } /*@internal*/ function isCircularBuildOrder(buildOrder) { return !!buildOrder && !!buildOrder.buildOrder; @@ -123422,8 +123842,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -123969,7 +124389,7 @@ var ts; outputFiles.forEach(function (_a) { var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; var priorChangeTime; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && ts.isDeclarationFileName(name)) { // Check for unchanged .d.ts files if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); @@ -124198,7 +124618,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -124227,7 +124647,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -124255,7 +124675,7 @@ var ts; if (!host.fileExists(inputFile)) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (!force) { @@ -124310,7 +124730,7 @@ var ts; // In addition to file timestamps, we also keep track of when a .d.ts file // had its file touched but not had its contents changed - this allows us // to skip a downstream typecheck - if (isDeclarationFile(output)) { + if (ts.isDeclarationFileName(output)) { var outputModifiedTime = ts.getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -124464,7 +124884,7 @@ var ts; reportVerbose = false; reportStatus(state, verboseMessage, proj.options.configFilePath); } - if (isDeclarationFile(file)) { + if (ts.isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); @@ -124614,7 +125034,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -124717,7 +125137,7 @@ var ts; if (!state.watch || !state.lastCachedPackageJsonLookups) return; ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { - createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, onDeleteValue: ts.closeFileWatcher, }); } @@ -125045,6 +125465,17 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + // Do not change existing values, as they exist in telemetry. + var CompletionInfoFlags; + (function (CompletionInfoFlags) { + CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports"; + CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion"; + CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets"; + })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {})); var OutliningSpanKind; (function (OutliningSpanKind) { /** Single or multi-line comments */ @@ -125251,7 +125682,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -125262,66 +125693,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -125329,7 +125760,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -125338,24 +125769,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -125363,11 +125794,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -125379,27 +125810,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -125408,17 +125839,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -125485,7 +125916,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -125546,22 +125977,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -125585,17 +126016,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -125603,108 +126034,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -125769,42 +126200,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -125813,66 +126244,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -125889,7 +126320,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -125932,13 +126363,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -125997,11 +126428,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -126091,30 +126522,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -126140,7 +126571,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -126156,13 +126587,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -126181,12 +126612,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -126194,13 +126625,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -126211,20 +126642,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -126239,29 +126670,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -126332,23 +126763,23 @@ var ts; // position and whose end is greater than the position. var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input if (nodeContainsPosition(children[middle])) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -126374,7 +126805,7 @@ var ts; return false; } var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -126443,7 +126874,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -126455,11 +126886,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -126484,7 +126915,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -126515,7 +126946,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -126551,25 +126982,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -126588,10 +127019,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -126600,17 +127031,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -126700,10 +127131,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -126713,56 +127144,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -126794,52 +127225,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -126847,7 +127278,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -126857,9 +127288,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -126872,18 +127303,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -126891,7 +127322,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -126914,8 +127345,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -126953,32 +127384,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -126987,7 +127418,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -127015,7 +127446,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -127030,7 +127461,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -127057,6 +127488,14 @@ var ts; return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } }); } ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost; + function moduleResolutionRespectsExports(moduleResolution) { + return moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports; + function moduleResolutionUsesNodeModules(moduleResolution) { + return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules; function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) { return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined; } @@ -127071,7 +127510,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -127080,25 +127519,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -127109,12 +127548,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -127158,7 +127597,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -127336,34 +127775,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -127440,7 +127879,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -127467,8 +127906,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -127518,22 +127957,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -127543,7 +127982,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -127571,10 +128010,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -127663,14 +128102,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -127689,7 +128128,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -127706,7 +128145,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -127763,7 +128202,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -127789,7 +128228,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -127797,15 +128236,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -127816,15 +128255,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -127833,10 +128272,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -127856,9 +128295,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -127870,48 +128309,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -127931,12 +128370,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -127960,7 +128399,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -127969,10 +128408,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -128096,16 +128535,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -128200,7 +128639,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -128320,20 +128759,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -128366,7 +128805,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -128384,7 +128823,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -128397,7 +128836,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -128417,7 +128856,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -128489,7 +128928,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -128498,7 +128937,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -128506,8 +128945,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -128596,9 +129035,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -128611,7 +129050,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -128660,8 +129099,8 @@ var ts; if (from === to) return false; var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {}); - if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) { - return cachedResult.isAutoImportable; + if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) { + return !cachedResult.isBlockedByPackageJsonDependencies; } var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); @@ -128675,7 +129114,7 @@ var ts; }); if (packageJsonFilter) { var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); - moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable); return isAutoImportable; } return hasImportablePath; @@ -128700,7 +129139,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -128737,24 +129176,31 @@ var ts; (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results"); var compilerOptions = program.getCompilerOptions(); var moduleCount = 0; - forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { - if (++moduleCount % 100 === 0) - cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); - var seenExports = new ts.Map(); - var checker = program.getTypeChecker(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - // Note: I think we shouldn't actually see resolved module symbols here, but weird merges - // can cause it to happen: see 'completionsImport_mergedReExport.ts' - if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); - } - checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { - if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + try { + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { + if (++moduleCount % 100 === 0) + cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); + var seenExports = new ts.Map(); + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + // Note: I think we shouldn't actually see resolved module symbols here, but weird merges + // can cause it to happen: see 'completionsImport_mergedReExport.ts' + if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } + checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); + } + }); }); - }); - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + } + catch (err) { + // Ensure cache is reset if operation is cancelled + cache.clear(); + throw err; + } + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -128773,10 +129219,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -128785,7 +129231,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -128795,8 +129241,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -128808,7 +129254,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -128818,15 +129264,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -128852,10 +129298,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -128891,68 +129337,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -128961,15 +129407,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -128983,59 +129429,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -129077,23 +129523,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -129107,10 +129553,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -129123,19 +129569,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -129143,47 +129589,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -129191,12 +129637,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -129204,36 +129650,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -129253,13 +129699,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -129284,10 +129730,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -129296,29 +129742,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -129327,35 +129773,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -129381,11 +129827,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -129407,12 +129853,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -129420,21 +129866,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -129443,7 +129889,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -129454,7 +129900,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -129463,7 +129909,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -129476,51 +129922,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -129539,7 +129985,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -129549,7 +129995,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -129574,9 +130020,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -129590,19 +130036,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -129610,7 +130056,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -129634,7 +130080,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -129661,10 +130107,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -129677,24 +130123,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -129705,97 +130151,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -129871,14 +130317,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -129890,13 +130336,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -129912,7 +130358,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -129921,38 +130367,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -129965,22 +130411,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -129990,17 +130436,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -130042,25 +130488,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -130091,19 +130537,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -130122,16 +130568,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -130147,20 +130593,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -130174,18 +130620,18 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { + case 196 /* SyntaxKind.LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -130197,21 +130643,21 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -130228,7 +130674,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -130241,41 +130687,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -130302,14 +130748,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -130318,10 +130764,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -130332,13 +130778,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -130360,11 +130806,11 @@ var ts; : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -130378,11 +130824,11 @@ var ts; } function isEmitResolutionKindUsingNodeModules(compilerOptions) { return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs || - ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function isEmitModuleResolutionRespectingExportMaps(compilerOptions) { - return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -130457,16 +130903,16 @@ var ts; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } var foundFileName = void 0; var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { + else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); foundFiles.set(foundFileName, outputExtension); } @@ -130476,7 +130922,7 @@ var ts; } } foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + result.push(nameAndKind(foundFile, "script" /* ScriptElementKind.scriptElement */, ext)); }); } // If possible, get folder completion as well @@ -130547,7 +130993,7 @@ var ts; var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -130558,7 +131004,7 @@ var ts; var _loop_4 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -130619,7 +131065,7 @@ var ts; }); ts.forEach(processedKeys, function (k) { if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(k, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }); return; @@ -130678,7 +131124,7 @@ var ts; var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); + return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* ScriptElementKind.scriptElement */, extension); }); var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); @@ -130723,7 +131169,7 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, names); @@ -130754,7 +131200,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -130796,14 +131242,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -130860,7 +131306,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -130902,16 +131348,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -130920,16 +131366,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -130942,7 +131388,7 @@ var ts; KeywordCompletionFilters[KeywordCompletionFilters["TypeAssertionKeywords"] = 6] = "TypeAssertionKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeywords"] = 7] = "TypeKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeyword"] = 8] = "TypeKeyword"; - KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 7] = "Last"; + KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 8] = "Last"; })(KeywordCompletionFilters || (KeywordCompletionFilters = {})); var GlobalsSearch; (function (GlobalsSearch) { @@ -130950,43 +131396,54 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) { + function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) { var _a, _b, _c; var start = ts.timestamp(); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - var resolutionLimitExceeded = false; + // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because + // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a + // relative path into node_modules), and we want to filter those completions out entirely. + // Import statement completions always need specifier resolution because the module specifier is + // part of their `insertText`, not the `codeActions` creating edits away from the cursor. + var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions())); + var skippedAny = false; var ambientCount = 0; var resolvedCount = 0; var resolvedFromCacheCount = 0; var cacheAttemptCount = 0; - var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var result = cb({ + tryResolve: tryResolve, + skippedAny: function () { return skippedAny; }, + resolvedAny: function () { return resolvedCount > 0; }, + resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, + }); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; - function tryResolve(exportInfo, isFromAmbientModule) { + function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { - var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences); + var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences); if (result_1) { ambientCount++; } - return result_1; + return result_1 || "failed"; } - var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; + var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit; var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache) - ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) + ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) : undefined; if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) { - resolutionLimitExceeded = true; + skippedAny = true; } resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0; - resolvedFromCacheCount += exportInfo.length - resolvedCount; + resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0); if (shouldGetModuleSpecifierFromCache) { cacheAttemptCount++; } - return result; + return result || (needsFullResolution ? "failed" : "skipped"); } } function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) { @@ -131006,7 +131463,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -131020,7 +131477,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -131028,21 +131485,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -131059,16 +131516,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -131081,9 +131538,10 @@ var ts; return undefined; var lowerCaseTokenText = location.text.toLowerCase(); var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken); - var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences, - /*isForImportStatementCompletion*/ false, function (context) { + var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences, + /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) { var entries = ts.mapDefined(previousResponse.entries, function (entry) { + var _a; if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) { // Not an auto import or already resolved; keep as is return entry; @@ -131094,10 +131552,14 @@ var ts; } var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin; var info = exportMap.get(file.path, entry.data.exportMapKey); - var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); - if (!result) + var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); + if (result === "skipped") return entry; - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + if (!result || result === "failed") { + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); + return undefined; + } + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -131105,12 +131567,13 @@ var ts; entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)]; return entry; }); - if (!context.resolutionLimitExceeded()) { + if (!context.skippedAny()) { previousResponse.isIncomplete = undefined; } return entries; }); previousResponse.entries = newEntries; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -131119,8 +131582,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -131134,25 +131597,25 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; @@ -131165,17 +131628,17 @@ var ts; getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { + if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { return undefined; } getCompletionEntriesFromSymbols(symbols, entries, /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); } - if (keywordFilters !== 0 /* None */) { + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (!entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } @@ -131192,12 +131655,13 @@ var ts; ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); } return { + flags: completionData.flags, isGlobalCompletion: isInSnippetScope, isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, optionalReplacementSpan: getOptionalReplacementSpan(location), - entries: entries + entries: entries, }; } function isUncheckedFile(sourceFile, compilerOptions) { @@ -131205,9 +131669,9 @@ var ts; } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -131217,12 +131681,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -131241,14 +131705,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -131267,7 +131731,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -131280,7 +131744,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -131297,18 +131761,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -131319,7 +131783,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -131332,8 +131796,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -131343,12 +131807,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -131359,28 +131823,24 @@ var ts; } } if (origin && originIsObjectLiteralMethod(origin)) { - var importAdder = void 0; - (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails); + (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails); if (!preferences.useLabelDetailsInCompletionEntries) { name = name + labelDetails.detail; labelDetails = undefined; } source = CompletionSource.ObjectLiteralMethodSnippet; sortText = Completions.SortText.SortBelow(sortText); - if (importAdder.hasFixes()) { - hasAction = true; - } } if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -131389,7 +131849,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -131431,8 +131891,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -131491,16 +131951,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -131511,13 +131971,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -131528,9 +131988,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -131545,9 +132005,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -131592,8 +132052,7 @@ var ts; var isSnippet = preferences.includeCompletionsWithSnippetText || undefined; var insertText = name; var sourceFile = enclosingDeclaration.getSourceFile(); - var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host); - var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder); + var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences); if (!method) { return undefined; } @@ -131605,10 +132064,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -131621,33 +132080,32 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; - return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; + return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; - function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) { + function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } var checker = program.getTypeChecker(); - var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var declaration = declarations[0]; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -131655,7 +132113,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -131664,47 +132122,72 @@ var ts; if (!typeNode || !ts.isFunctionTypeNode(typeNode)) { return undefined; } - var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); - if (importableReference) { - typeNode = importableReference.typeNode; - ts.codefix.importSymbols(importAdder, importableReference.symbols); - } var body = void 0; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } + var parameters = typeNode.parameters.map(function (typedParam) { + return ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken, + /*type*/ undefined, typedParam.initializer); + }); return ts.factory.createMethodDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, - /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body); + /*questionToken*/ undefined, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } default: return undefined; } } function createSnippetPrinter(printerOptions) { + var escapes; var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions)); var printer = ts.createPrinter(printerOptions, baseWriter); - var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } }); + var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } }); return { printSnippetList: printSnippetList, printAndFormatSnippetList: printAndFormatSnippetList, }; + // The formatter/scanner will have issues with snippet-escaped text, + // so instead of writing the escaped text directly to the writer, + // generate a set of changes that can be applied to the unescaped text + // to escape it post-formatting. + function escapingWrite(s, write) { + var escaped = ts.escapeSnippetText(s); + if (escaped !== s) { + var start = baseWriter.getTextPos(); + write(); + var end = baseWriter.getTextPos(); + escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } }); + } + else { + write(); + } + } /* Snippet-escaping version of `printer.printList`. */ function printSnippetList(format, list, sourceFile) { + var unescaped = printUnescapedSnippetList(format, list, sourceFile); + return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped; + } + function printUnescapedSnippetList(format, list, sourceFile) { + escapes = undefined; writer.clear(); printer.writeList(format, list, sourceFile, writer); return writer.getText(); } function printAndFormatSnippetList(format, list, sourceFile, formatContext) { var syntheticFile = { - text: printSnippetList(format, list, sourceFile), + text: printUnescapedSnippetList(format, list, sourceFile), getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); }, @@ -131716,7 +132199,10 @@ var ts; /* indentation */ 0, /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions })); }); - return ts.textChanges.applyChanges(syntheticFile.text, changes); + var allChanges = escapes + ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); }) + : changes; + return ts.textChanges.applyChanges(syntheticFile.text, allChanges); } } function originToCompletionEntryData(origin) { @@ -131742,11 +132228,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -131758,7 +132244,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -131774,21 +132260,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -131799,7 +132285,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -131808,10 +132294,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -131830,7 +132316,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -131883,7 +132369,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -131891,7 +132377,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -131915,8 +132401,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -131947,7 +132433,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -131961,8 +132447,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -131982,14 +132468,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -132001,22 +132487,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -132045,20 +132531,6 @@ var ts; }; } } - if (source === CompletionSource.ObjectLiteralMethodSnippet) { - var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken); - var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder; - if (importAdder.hasFixes()) { - var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes); - return { - sourceDisplay: undefined, - codeActions: [{ - changes: changes, - description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]), - }], - }; - } - } if (originIsTypeOnlyAlias(origin)) { var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences); ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias"); @@ -132070,7 +132542,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -132102,7 +132574,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -132110,31 +132582,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -132142,14 +132614,14 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -132165,10 +132637,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -132189,7 +132661,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -132199,21 +132671,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -132244,15 +132716,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -132265,6 +132738,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -132274,11 +132748,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -132286,7 +132760,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -132294,18 +132768,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -132313,58 +132787,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -132372,16 +132846,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -132390,7 +132864,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -132409,8 +132883,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -132418,8 +132892,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -132433,10 +132907,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -132457,16 +132931,17 @@ var ts; isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, + flags: flags, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -132475,13 +132950,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -132496,7 +132971,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -132504,7 +132979,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -132518,7 +132993,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -132532,7 +133007,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -132556,7 +133031,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -132564,7 +133039,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; if (inUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -132611,21 +133086,21 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, symbol: firstAccessibleSymbol, targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags, - }], sourceFile, program, host, preferences) || {}).moduleSpecifier; + }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -132656,15 +133131,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -132680,44 +133155,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -132752,7 +133227,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -132762,21 +133237,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -132785,8 +133260,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -132810,10 +133285,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -132829,29 +133304,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -132866,6 +133341,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -132877,50 +133353,72 @@ var ts; var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken); var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host); var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host); - resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) { + resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) { exportInfo.search(sourceFile.path, /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) { if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings()))) return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText); }, function (info, symbolName, isFromAmbientModule, exportMapKey) { + var _a; if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) { return; } - var defaultExportInfo = ts.find(info, isImportableExportInfo); - if (!defaultExportInfo) { + // Do a relatively cheap check to bail early if all re-exports are non-importable + // due to file location or package.json dependency filtering. For non-node16+ + // module resolution modes, getting past this point guarantees that we'll be + // able to generate a suitable module specifier, so we can safely show a completion, + // even if we defer computing the module specifier. + var firstImportableExportInfo = ts.find(info, isImportableExportInfo); + if (!firstImportableExportInfo) { return; } - // If we don't need to resolve module specifiers, we can use any re-export that is importable at all - // (We need to ensure that at least one is importable to show a completion.) - var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier; - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + // In node16+, module specifier resolution can fail due to modules being blocked + // by package.json `exports`. If that happens, don't show a completion item. + // N.B. in this resolution mode we always try to resolve module specifiers here, + // because we have to know now if it's going to fail so we can omit the completion + // from the list. + var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {}; + if (result === "failed") + return; + // If we skipped resolving module specifiers, our selection of which ExportInfo + // to use here is arbitrary, since the info shown in the completion list derived from + // it should be identical regardless of which one is used. During the subsequent + // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick + // the best one based on the module specifier it produces. + var exportInfo = firstImportableExportInfo, moduleSpecifier; + if (result !== "skipped") { + (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); + } + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, isFromPackageJson: exportInfo.isFromPackageJson, }); }); - hasUnresolvedAutoImports = context.resolutionLimitExceeded(); + hasUnresolvedAutoImports = context.skippedAny(); + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -132957,7 +133455,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -132967,7 +133465,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -132982,7 +133481,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -133009,27 +133508,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -133040,45 +133539,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -133097,21 +133596,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -133123,22 +133622,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -133148,12 +133647,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -133164,19 +133663,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -133188,14 +133687,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -133212,38 +133711,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -133256,14 +133755,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -133272,7 +133771,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -133281,48 +133780,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -133336,8 +133835,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -133367,23 +133866,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -133394,8 +133893,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -133403,10 +133902,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -133414,7 +133913,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -133433,75 +133932,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -133522,21 +134021,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -133545,7 +134044,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -133556,7 +134055,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -133572,22 +134071,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -133605,13 +134104,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -133624,7 +134123,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -133658,7 +134157,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -133683,7 +134182,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -133702,10 +134201,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -133713,11 +134212,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -133728,7 +134227,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -133747,7 +134246,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -133770,15 +134269,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -133801,12 +134300,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -133815,27 +134314,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -133845,11 +134344,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -133858,7 +134357,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 7 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -133867,30 +134366,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -133898,63 +134397,63 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -133975,9 +134474,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -133993,7 +134492,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -134015,7 +134514,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -134023,7 +134522,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -134041,15 +134540,15 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -134063,22 +134562,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -134089,7 +134588,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -134098,15 +134597,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -134123,11 +134622,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -134149,13 +134648,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -134168,22 +134667,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -134191,7 +134690,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -134208,7 +134707,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -134216,23 +134715,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -134242,12 +134741,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -134287,8 +134786,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -134325,8 +134824,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -134340,7 +134839,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -134370,7 +134869,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -134400,45 +134899,47 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); + case 101 /* SyntaxKind.InKeyword */: + return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -134480,7 +134981,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -134512,16 +135013,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -134537,41 +135038,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -134590,12 +135091,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -134603,7 +135104,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -134612,13 +135113,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -134626,13 +135127,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -134640,13 +135141,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -134657,13 +135158,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -134675,11 +135176,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -134691,13 +135192,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -134712,7 +135213,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -134731,7 +135232,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -134746,7 +135247,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -134766,10 +135267,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -134853,7 +135354,7 @@ var ts; } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { @@ -134861,7 +135362,7 @@ var ts; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); var sourceFileOptions = { languageVersion: scriptTarget, impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), @@ -134874,15 +135375,15 @@ var ts; // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). - var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) && + var otherBucketKey = !ts.isDeclarationFileName(path) && ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); } } var bucketEntry = bucket.get(path); @@ -134996,18 +135497,18 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -135074,43 +135575,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -135119,7 +135620,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -135141,18 +135642,18 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* SyntaxKind.ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -135174,7 +135675,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -135208,33 +135709,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -135243,12 +135744,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -135259,7 +135760,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -135271,7 +135772,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -135296,7 +135797,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -135305,7 +135806,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -135325,7 +135826,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -135373,7 +135874,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -135388,15 +135889,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -135421,7 +135922,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -135434,21 +135935,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -135466,24 +135967,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -135510,22 +136011,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -135555,16 +136056,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; @@ -135594,7 +136095,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -135605,21 +136106,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -135646,7 +136147,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -135674,7 +136175,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -135713,7 +136214,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -135722,7 +136223,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -135730,28 +136231,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -135792,7 +136293,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -135809,19 +136310,19 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } else { @@ -135844,18 +136345,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -135863,7 +136364,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -135882,7 +136383,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -135890,32 +136391,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -135923,7 +136424,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -135946,19 +136447,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -135968,7 +136469,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -135976,10 +136477,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -136013,12 +136514,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -136026,16 +136527,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -136044,17 +136545,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -136069,14 +136570,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -136084,9 +136585,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -136097,50 +136598,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -136169,7 +136670,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -136191,7 +136692,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -136201,11 +136702,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -136216,10 +136717,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -136247,7 +136748,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -136267,10 +136768,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -136298,13 +136799,13 @@ var ts; continue; } var _loop_5 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -136335,7 +136836,7 @@ var ts; return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -136356,7 +136857,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -136366,21 +136867,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -136388,41 +136889,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -136438,7 +136939,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -136447,20 +136948,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -136483,17 +136984,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -136506,10 +137007,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -136523,7 +137024,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -136575,7 +137076,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -136598,7 +137099,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -136606,7 +137107,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -136637,19 +137138,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -136662,7 +137163,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -136690,13 +137191,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -136706,7 +137207,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -136732,17 +137233,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -136759,7 +137260,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -136771,7 +137272,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -136819,6 +137320,30 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function getTopMostDeclarationNamesInFile(declarationName, sourceFile) { + var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); }); + return candidates.reduce(function (topMost, decl) { + var depth = getDepth(decl); + if (!ts.some(topMost.declarationNames) || depth === topMost.depth) { + topMost.declarationNames.push(decl); + topMost.depth = depth; + } + else if (depth < topMost.depth) { + topMost.declarationNames = [decl]; + topMost.depth = depth; + } + return topMost; + }, { depth: Infinity, declarationNames: [] }).declarationNames; + function getDepth(declaration) { + var depth = 0; + while (declaration) { + declaration = ts.getContainerNode(declaration); + depth++; + } + return depth; + } + } + Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile; function someSignatureUsage(signature, sourceFiles, checker, cb) { if (!signature.name || !ts.isIdentifier(signature.name)) return false; @@ -136866,8 +137391,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -136882,27 +137407,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -136918,7 +137443,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -136929,7 +137454,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -136980,7 +137505,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -136990,14 +137515,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -137005,7 +137530,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -137025,7 +137550,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -137035,7 +137560,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -137046,9 +137571,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -137056,7 +137581,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -137083,11 +137608,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -137107,14 +137632,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -137132,7 +137657,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -137148,7 +137673,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -137159,7 +137684,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -137178,18 +137703,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -137200,7 +137725,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -137210,10 +137735,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -137237,10 +137762,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -137260,7 +137785,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -137288,13 +137813,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -137345,15 +137870,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -137362,7 +137887,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -137371,46 +137896,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -137418,26 +137943,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -137450,18 +137975,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -137506,30 +138031,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -137539,14 +138064,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -137561,7 +138086,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -137569,7 +138094,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -137581,13 +138106,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -137609,7 +138134,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -137623,12 +138148,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -137638,7 +138163,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -137678,7 +138203,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -137689,7 +138214,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -137718,12 +138243,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -137743,7 +138268,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -137792,7 +138317,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -137816,8 +138341,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -137837,7 +138362,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -137850,16 +138375,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -137957,7 +138482,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -137968,7 +138493,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -137998,7 +138523,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -138028,7 +138553,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -138056,7 +138581,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -138073,59 +138598,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -138142,7 +138667,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -138181,25 +138706,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -138215,7 +138740,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -138455,7 +138980,9 @@ var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { - function getDefinitionAtPosition(program, sourceFile, position) { + function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) { + var _a; + var _b; var resolvedRef = getReferenceAtPosition(sourceFile, position, program); var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { @@ -138468,45 +138995,75 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; - var symbol_1 = getSymbol(classDecl, typeChecker); + var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution; var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration); var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : ""; var sourceFile_1 = node.getSourceFile(); return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } - var symbol = getSymbol(node, typeChecker); + var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; + var fallbackNode = node; + if (searchOtherFilesOnly && failedAliasResolution) { + // We couldn't resolve the specific import, try on the module specifier. + var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); }); + var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration); + if (moduleSpecifier) { + (_a = getSymbol(moduleSpecifier, typeChecker, stopAtAlias), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution); + fallbackNode = moduleSpecifier; + } + } + if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) { + // We couldn't resolve the module specifier as an external module, but it could + // be that module resolution succeeded but the target was not a module. + var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode)); + if (ref) { + return [{ + name: fallbackNode.text, + fileName: ref.resolvedFileName, + containerName: undefined, + containerKind: undefined, + kind: "script" /* ScriptElementKind.scriptElement */, + textSpan: ts.createTextSpan(0, 0), + failedAliasResolution: failedAliasResolution, + isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), + unverified: fallbackNode !== node, + }]; + } + } // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } + if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; })) + return undefined; var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) { - var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); + var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) { return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -138514,9 +139071,9 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray; + var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the @@ -138539,7 +139096,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -138637,24 +139194,24 @@ var ts; return undefined; } if (ts.isImportMeta(node.parent) && node.parent.name === node) { - return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent); + return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false); } - var symbol = getSymbol(node, typeChecker); + var _a = getSymbol(node, typeChecker, /*stopAtAlias*/ false), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution; if (!symbol) return undefined; var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node); var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker); - var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node); + var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution); // If a function returns 'void' or some other type with no definition, just return the function definition. - var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node); + var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; - function definitionFromType(type, checker, node) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { - return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node); + function definitionFromType(type, checker, node, failedAliasResolution) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { + return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } function tryGetReturnTypeOfFunction(symbol, type, checker) { @@ -138690,19 +139247,23 @@ var ts; function getDefinitionInfoForIndexSignatures(node, checker) { return ts.mapDefined(checker.getIndexInfosAtLocation(node), function (info) { return info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); }); } - function getSymbol(node, checker) { + function getSymbol(node, checker, stopAtAlias) { var symbol = checker.getSymbolAtLocation(node); // If this is an alias, and the request came at the declaration location // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + var failedAliasResolution = false; + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { - return aliased; + return { symbol: aliased }; + } + else { + failedAliasResolution = true; } } - return symbol; + return { symbol: symbol, failedAliasResolution: failedAliasResolution }; } // Go to the original declaration for cases: // @@ -138710,36 +139271,55 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - switch (declaration.kind) { - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: - return true; - case 270 /* ImportSpecifier */: - return declaration.parent.kind === 269 /* NamedImports */; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); - default: - return false; + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { + return false; } + return true; } - function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { - // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties. - // For deduping purposes, we also want to exclude any declarationNodes if provided. - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) - || undefined; - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + /** + * ```ts + * function f() {} + * f.foo = 0; + * ``` + * + * Here, `f` has two declarations: the function declaration, and the identifier in the next line. + * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so + * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a + * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this + * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the + * declaration looks like an assignment, that declaration is in no sense a definition for `f`. + * But that information is totally lost during binding and/or symbol merging, so we need to do + * our best to reconstruct it or use other heuristics. This function (and the logic around its + * calling) covers our tests but feels like a hack, and it would be great if someone could come + * up with a more precise definition of what counts as a definition. + */ + function isExpandoDeclaration(node) { + if (!ts.isAssignmentDeclaration(node)) + return false; + var containingAssignment = ts.findAncestor(node, function (p) { + if (ts.isAssignmentExpression(p)) + return true; + if (!ts.isAssignmentDeclaration(p)) + return "quit"; + return false; + }); + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; + } + function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); + var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); }); + var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -138759,26 +139339,27 @@ var ts; return declarations.length ? declarationsWithBody.length !== 0 ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) - : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)] : undefined; } } /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ - function createDefinitionInfo(declaration, checker, symbol, node) { + function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) { var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node); var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : ""; - return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName); + return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution); } + GoToDefinition.createDefinitionInfo = createDefinitionInfo; /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) { + function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) { var sourceFile = declaration.getSourceFile(); if (!textSpan) { var name = ts.getNameOfDeclaration(declaration) || declaration; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -138790,29 +139371,29 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; } } - function createDefinitionFromSignatureDeclaration(typeChecker, decl) { - return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); + function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) { + return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution); } function findReferenceInPosition(refs, pos) { return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); @@ -138822,7 +139403,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -138843,9 +139424,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -138957,10 +139538,10 @@ var ts; // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = getDisplayPartsFromComment(jsdoc.comment, checker); @@ -138977,11 +139558,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -138995,8 +139576,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -139011,17 +139592,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -139035,7 +139616,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -139043,13 +139624,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -139076,14 +139657,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -139093,7 +139674,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -139104,8 +139685,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -139115,7 +139696,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139141,14 +139722,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139235,37 +139816,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -139275,25 +139856,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -139306,14 +139887,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -139372,9 +139953,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -139384,7 +139965,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -139401,7 +139982,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -139435,7 +140016,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -139618,7 +140199,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -139631,7 +140212,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -139643,25 +140224,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -139673,7 +140254,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -139684,17 +140265,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -139704,7 +140285,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -139712,11 +140293,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -139726,9 +140307,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -139736,10 +140317,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -139753,27 +140334,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -139787,7 +140368,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -139807,10 +140388,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -139823,7 +140404,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -139841,9 +140422,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -139899,16 +140480,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -139916,10 +140497,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -139985,7 +140566,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -140004,12 +140585,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -140017,7 +140598,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -140031,7 +140612,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -140061,7 +140642,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -140070,53 +140651,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -140149,19 +140730,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -140171,10 +140752,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -140236,7 +140817,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -140250,13 +140831,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -140271,7 +140852,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -140279,7 +140860,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -140290,10 +140871,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -140306,7 +140887,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -140314,9 +140895,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -140430,7 +141011,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -140448,7 +141029,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -140717,11 +141298,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -140760,19 +141341,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -140825,7 +141406,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -140833,7 +141414,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -140883,7 +141464,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -140918,7 +141499,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -140934,9 +141515,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -140947,7 +141528,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -140961,7 +141542,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -140969,23 +141550,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -140993,52 +141574,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -141049,33 +141630,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -141084,32 +141665,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -141119,12 +141700,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -141250,7 +141831,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -141302,7 +141883,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -141379,10 +141960,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -141392,10 +141973,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -141420,10 +142001,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -141432,10 +142013,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -141504,35 +142085,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -141593,7 +142174,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -141614,10 +142195,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -141647,12 +142228,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -141664,54 +142245,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -141720,18 +142301,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -141739,15 +142320,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -141763,31 +142344,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -141795,31 +142376,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -141833,12 +142414,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -141849,16 +142430,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -141867,15 +142448,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -141903,31 +142484,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -142014,13 +142595,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -142033,14 +142614,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -142049,7 +142630,7 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { @@ -142060,7 +142641,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -142070,7 +142651,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -142100,13 +142681,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -142138,7 +142719,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -142206,7 +142787,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -142263,26 +142844,26 @@ var ts; if (ts.isMappedTypeNode(node)) { var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -142294,7 +142875,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -142307,14 +142888,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -142370,7 +142951,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -142385,25 +142966,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -142450,7 +143031,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -142464,27 +143045,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -142494,20 +143075,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -142543,7 +143124,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -142560,7 +143141,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -142603,7 +143184,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -142613,10 +143194,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -142641,7 +143222,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -142651,7 +143232,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -142680,28 +143261,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -142711,7 +143292,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -142733,7 +143314,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -142752,8 +143333,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -142791,7 +143372,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -142822,7 +143403,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -142834,7 +143415,7 @@ var ts; var _loop_9 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; @@ -142854,17 +143435,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -142921,10 +143502,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -142957,9 +143538,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -142967,33 +143548,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -143006,7 +143587,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -143027,14 +143608,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -143070,25 +143651,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -143102,7 +143683,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name)) { @@ -143174,17 +143755,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -143193,7 +143774,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -143216,7 +143797,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -143258,13 +143839,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -143326,7 +143907,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -143435,7 +144016,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -143471,7 +144052,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -143493,16 +144074,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -143514,12 +144095,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -143589,26 +144170,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -143621,28 +144202,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -143655,32 +144236,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -143688,52 +144269,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -143741,23 +144322,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -143767,10 +144348,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -143778,10 +144359,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -143792,41 +144373,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -143846,7 +144427,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -143854,21 +144435,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -143877,29 +144458,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -143909,31 +144490,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -143943,63 +144524,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -144010,7 +144591,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -144018,21 +144599,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -144040,22 +144621,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -144064,7 +144645,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -144080,42 +144661,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -144125,30 +144706,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144159,17 +144740,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -144185,14 +144766,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -144243,23 +144824,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -144274,31 +144855,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -144310,7 +144891,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144322,16 +144903,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -144536,8 +145117,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -144555,8 +145136,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -144568,7 +145149,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -144596,7 +145177,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -144624,11 +145205,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -144636,12 +145217,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -144650,29 +145231,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -144704,7 +145285,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -144715,40 +145296,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -144757,15 +145338,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -144832,8 +145413,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -144845,263 +145426,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -145119,7 +145700,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -145160,54 +145741,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -145219,22 +145800,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -145260,34 +145841,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -145296,40 +145877,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -145338,71 +145919,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -145417,45 +145998,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -145466,28 +146047,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -145509,15 +146090,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -145526,25 +146107,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -145573,17 +146154,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -145632,12 +146213,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -145663,7 +146244,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -145732,16 +146313,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -145763,12 +146344,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -145776,7 +146357,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -145785,7 +146366,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -145825,17 +146406,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -145932,11 +146513,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -145950,7 +146531,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -145978,7 +146559,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -146023,7 +146604,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -146038,7 +146619,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -146051,8 +146632,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -146075,19 +146656,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -146102,12 +146683,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -146134,26 +146715,26 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: - case 228 /* ExpressionWithTypeArguments */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -146188,7 +146769,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -146201,6 +146782,9 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + if (ts.nodeIsMissing(child)) { + return inheritedIndentation; + } var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; var undecoratedChildStartLine = childStartLine; @@ -146208,10 +146792,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -146247,17 +146831,17 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -146267,7 +146851,14 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; - if (listStartToken !== 0 /* Unknown */) { + // node range is outside the target range - do not dive inside + if (!ts.rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { + if (nodes.end < originalRange.pos) { + formattingScanner.skipToEndOf(nodes); + } + return; + } + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -146280,7 +146871,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -146299,15 +146890,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */ && ts.isCallLikeExpression(parent)) { var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; if (startLine !== commaTokenLine) { formattingScanner.advance(); @@ -146331,7 +146922,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -146341,13 +146932,13 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } @@ -146357,15 +146948,15 @@ var ts; if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -146379,19 +146970,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -146409,7 +147000,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -146430,7 +147021,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -146438,14 +147029,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -146454,15 +147045,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -146488,7 +147079,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -146619,48 +147210,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -146702,53 +147293,53 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -146834,7 +147425,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -146870,21 +147461,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -146904,7 +147495,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -146929,9 +147520,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -146940,7 +147531,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -146994,12 +147585,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -147038,7 +147629,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -147049,9 +147640,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -147064,13 +147655,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -147080,9 +147671,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -147097,8 +147688,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -147178,42 +147769,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -147231,27 +147822,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -147260,7 +147851,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -147270,7 +147861,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -147291,7 +147882,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -147307,98 +147898,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -147409,11 +148000,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -147503,7 +148094,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -147587,7 +148178,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -147630,7 +148221,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -147736,7 +148327,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -147800,7 +148391,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -147853,7 +148444,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -147862,19 +148453,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -148015,8 +148606,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -148024,22 +148615,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -148048,28 +148639,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -148124,7 +148715,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -148141,12 +148732,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -148169,7 +148760,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -148246,10 +148837,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -148261,16 +148852,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -148279,8 +148870,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -148300,7 +148891,7 @@ var ts; var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); var _loop_12 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. @@ -148327,8 +148918,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -148383,7 +148974,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -148391,7 +148982,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -148401,7 +148992,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -148612,7 +149203,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -148652,7 +149243,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -148664,18 +149255,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -148686,17 +149277,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -148704,13 +149295,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -148719,17 +149310,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -148758,7 +149349,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -148780,15 +149371,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -148797,14 +149388,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -148991,8 +149582,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -149077,7 +149668,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -149127,7 +149718,7 @@ var ts; ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, - ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, + ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code, @@ -149221,12 +149812,12 @@ var ts; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -149294,15 +149885,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -149391,7 +149982,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -149415,16 +150006,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -149438,9 +150029,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -149450,10 +150041,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -149488,9 +150079,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -149605,7 +150196,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -149645,7 +150236,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -149698,9 +150289,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -149710,7 +150301,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -149725,30 +150316,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -149765,13 +150356,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -149809,11 +150400,11 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -149840,7 +150431,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -149873,14 +150464,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -149931,7 +150522,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -149950,7 +150541,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -150002,7 +150593,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150013,14 +150604,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150037,7 +150628,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150048,7 +150639,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150075,7 +150666,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -150136,7 +150727,7 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options); + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, options); var _loop_14 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { @@ -150211,7 +150802,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -150274,7 +150865,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -150355,7 +150946,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -150364,7 +150955,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -150384,7 +150975,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -150400,10 +150991,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -150413,7 +151004,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -150518,12 +151109,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -150539,11 +151130,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -150553,7 +151144,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -150564,8 +151155,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -150667,7 +151258,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -150684,7 +151275,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -150694,7 +151285,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -150776,12 +151367,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -150802,10 +151393,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -150843,10 +151434,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -150886,9 +151477,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -150906,29 +151497,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -150975,8 +151566,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -150984,11 +151575,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -151027,19 +151618,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -151068,8 +151659,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -151084,23 +151675,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -151108,10 +151699,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -151131,7 +151722,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -151146,7 +151737,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -151157,7 +151748,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -151168,10 +151759,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -151228,7 +151819,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -151250,11 +151841,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -151278,7 +151869,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -151308,7 +151899,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -151368,7 +151959,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -151537,7 +152128,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -151550,10 +152141,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -151649,7 +152240,7 @@ var ts; var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider); var useRequire = shouldUseRequire(sourceFile, program); - var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); + var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); if (fix) { addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined }); } @@ -151659,20 +152250,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -151685,32 +152276,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -151738,13 +152329,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -151754,7 +152345,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -151819,7 +152410,7 @@ var ts; : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences)); + var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences)); return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, @@ -151832,13 +152423,13 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; - function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host); + return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; @@ -151860,7 +152451,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -151883,7 +152474,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -151893,25 +152484,32 @@ var ts; return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); } } - function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { - var _a = getNewImportFixes(program, importingFile, - /*position*/ undefined, - /*isValidTypeOnlyUseSite*/ false, - /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; + function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { + var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, + /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host); return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount }); } codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; - function getImportFixes(exportInfos, symbolName, + function getImportFixes(exportInfos, useNamespaceInfo, /** undefined only for missing JSX namespace */ - position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) { + isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) { var checker = program.getTypeChecker(); var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); - var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); + var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker); var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions()); - // 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, position, isValidTypeOnlyUseSite, useRequire, host, preferences); - return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true); + if (addToExisting) { + // Don't bother providing an action to add a new import if we can add to an existing one. + return { + computedWithoutCacheCount: 0, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false), + }; + } + var _a = getFixesForAddImport(exportInfos, existingImports, program, sourceFile, useNamespaceInfo === null || useNamespaceInfo === void 0 ? void 0 : useNamespaceInfo.position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly), fixes = _a.fixes, _b = _a.computedWithoutCacheCount, computedWithoutCacheCount = _b === void 0 ? 0 : _b; + return { + computedWithoutCacheCount: computedWithoutCacheCount, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true), + }; } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -151927,13 +152525,14 @@ var ts; // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. return ts.firstDefined(existingImports, function (_a) { + var _b; var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -151941,11 +152540,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -151955,11 +152554,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -151968,31 +152567,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -152001,22 +152600,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -152027,7 +152626,7 @@ var ts; function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { @@ -152035,7 +152634,7 @@ var ts; if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } - if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } }); @@ -152073,6 +152672,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); }); + var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions)); var getModuleSpecifiers = fromCacheOnly ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); } : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); }; @@ -152080,38 +152680,39 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; - return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) { - // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return !importedSymbolHasValueMeaning && isJs && position !== undefined - ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } - : { - kind: 3 /* AddNew */, - moduleSpecifier: moduleSpecifier, - importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), - useRequire: useRequire, - addAsTypeOnly: addAsTypeOnly, - exportInfo: exportInfo, - isReExport: i > 0, - }; + return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { + return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : + // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + { + kind: 3 /* ImportFixKind.AddNew */, + moduleSpecifier: moduleSpecifier, + importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), + useRequire: useRequire, + addAsTypeOnly: addAsTypeOnly, + exportInfo: exportInfo, + isReExport: i > 0, + }; }); }); return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes }; } - function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); }); - return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes; + return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly); } function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) { + var _b; var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -152142,23 +152743,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -152181,10 +152782,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -152195,9 +152796,10 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences); + var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; + var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text }; } function getUmdSymbol(token, checker) { @@ -152208,7 +152810,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -152217,10 +152819,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -152228,7 +152830,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -152237,9 +152839,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -152247,12 +152849,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; - case ts.ModuleKind.Node12: + return 2 /* ImportKind.Namespace */; + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -152261,7 +152863,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -152269,19 +152871,19 @@ var ts; var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes; })); return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text }; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -152296,8 +152898,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -152329,7 +152931,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -152340,14 +152942,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -152356,12 +152958,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -152372,45 +152974,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -152418,7 +153020,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -152436,13 +153038,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -152454,7 +153056,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -152464,7 +153066,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -152473,7 +153075,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -152483,7 +153085,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -152534,7 +153136,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -152558,11 +153160,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -152571,12 +153173,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) @@ -152617,7 +153219,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -152654,7 +153256,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -152788,7 +153390,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -152796,19 +153398,19 @@ var ts; changeTracker.filterJSDocTags(sourceFile, classElement, ts.not(ts.isJSDocOverrideTag)); return; } - var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* OverrideKeyword */; }); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* SyntaxKind.OverrideKeyword */; }); ts.Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -152850,7 +153452,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -152890,7 +153492,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -152909,7 +153511,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -152940,7 +153542,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -152949,16 +153551,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -153024,18 +153626,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -153053,7 +153655,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -153086,14 +153688,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -153165,7 +153767,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -153224,7 +153826,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -153268,19 +153870,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -153342,19 +153944,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -153372,20 +153974,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -153409,15 +154011,15 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; @@ -153444,12 +154046,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -153458,7 +154060,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -153466,17 +154068,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -153488,13 +154090,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -153508,15 +154110,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -153532,18 +154134,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -153580,32 +154182,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -153633,7 +154235,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -153658,15 +154260,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -153686,7 +154288,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.decorators, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -153696,7 +154298,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } function addJsxAttributes(changes, context, info) { @@ -153724,7 +154326,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop)); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* QuotePreference.Single */), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -153734,42 +154336,42 @@ var ts; changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -153783,17 +154385,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -153808,8 +154410,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -153833,7 +154435,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -153918,7 +154520,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -153993,7 +154595,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -154036,7 +154638,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -154161,8 +154763,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { var compilerOptions = context.program.getCompilerOptions(); @@ -154180,7 +154782,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -154259,17 +154861,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -154366,7 +154968,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -154473,7 +155075,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -154488,7 +155090,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -154500,11 +155102,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -154512,7 +155114,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -154521,7 +155123,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -154557,7 +155159,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -154599,7 +155201,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -154641,13 +155243,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -154670,7 +155272,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -154681,7 +155283,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -154690,18 +155292,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -154710,15 +155312,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -154726,14 +155328,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -154783,8 +155385,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -154793,7 +155395,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -154814,20 +155416,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -154888,7 +155490,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -154899,8 +155501,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -154949,7 +155551,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -154973,10 +155575,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -154993,7 +155595,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -155010,22 +155612,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -155060,7 +155662,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -155128,15 +155730,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -155151,11 +155753,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -155317,7 +155919,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -155418,9 +156020,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -155428,7 +156030,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -155471,7 +156073,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -155507,7 +156109,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -155515,9 +156117,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -155526,7 +156128,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -155540,7 +156142,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -155558,19 +156160,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -155712,24 +156314,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -155737,20 +156339,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -155774,13 +156376,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -155790,65 +156392,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -155856,31 +156458,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -155900,7 +156502,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -155925,7 +156527,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -155972,21 +156574,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -156005,22 +156607,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -156052,7 +156654,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -156069,7 +156671,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -156097,7 +156699,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -156111,7 +156713,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -156130,10 +156732,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -156147,8 +156749,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -156184,10 +156786,10 @@ var ts; var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); var _loop_16 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; @@ -156195,15 +156797,15 @@ var ts; _loop_16(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -156287,7 +156889,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -156354,7 +156956,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -156367,13 +156969,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -156383,11 +156985,11 @@ var ts; } } addClassElement(ts.factory.createPropertyDeclaration( - /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -156416,8 +157018,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -156425,7 +157027,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!ts.some(signatures)) { break; } @@ -156447,13 +157049,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -156463,11 +157065,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 1073741824 /* NoUndefinedOptionalParameterType */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -156520,7 +157121,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -156552,26 +157153,26 @@ var ts; ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; var typeParameters = isJs || typeArguments === undefined ? undefined : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); + return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* CharacterCodes.T */ + typeArguments.length - 1 <= 90 /* CharacterCodes.Z */ ? String.fromCharCode(84 /* CharacterCodes.T */ + i) : "T".concat(i)); }); var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, /*questionToken*/ undefined, typeParameters, parameters, type); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: @@ -156599,9 +157200,9 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ names && names[i] || "arg".concat(i), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -156631,8 +157232,8 @@ var ts; if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -156648,7 +157249,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -156657,16 +157258,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -156739,7 +157340,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -156812,17 +157413,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -156831,7 +157432,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -156849,13 +157450,13 @@ var ts; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -156911,13 +157512,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -156932,7 +157533,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -156944,7 +157545,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -156991,7 +157592,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -157109,7 +157710,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -157117,7 +157718,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -157146,7 +157747,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -157155,7 +157756,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -157163,7 +157764,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -157339,8 +157940,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -157403,7 +158004,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -157469,7 +158070,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -157527,7 +158128,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -157538,7 +158139,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -157610,7 +158211,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -157647,14 +158248,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157667,6 +158268,7 @@ var ts; var fixName = "addVoidToPromise"; var fixId = "addVoidToPromise"; var errorCodes = [ + ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code, ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code ]; codefix.registerCodeFix({ @@ -157701,7 +158303,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -157713,14 +158315,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -157796,15 +158398,15 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var checker = program.getTypeChecker(); @@ -157813,22 +158415,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -157838,7 +158440,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -157862,18 +158464,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -157882,15 +158484,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -157911,18 +158513,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -157931,10 +158533,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -157945,7 +158547,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -157956,11 +158558,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -157973,7 +158575,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -157982,7 +158584,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -158001,17 +158603,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -158063,13 +158665,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -158077,11 +158679,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -158094,7 +158696,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -158143,14 +158745,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -158299,7 +158901,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -158315,7 +158917,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -158441,17 +159043,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -158466,7 +159068,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -158512,27 +159114,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -158554,24 +159156,24 @@ var ts; return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -158584,12 +159186,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -158715,7 +159317,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -158723,7 +159325,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -158739,7 +159341,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -158747,7 +159349,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -158843,6 +159445,7 @@ var ts; Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block"); + Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method"); })(Messages = extractSymbol.Messages || (extractSymbol.Messages = {})); var RangeFacts; (function (RangeFacts) { @@ -158851,10 +159454,11 @@ var ts; RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction"; /** * The range is in a function which needs the 'static' modifier in a class */ - RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion"; })(RangeFacts || (RangeFacts = {})); /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array @@ -158885,11 +159489,12 @@ var ts; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. var rangeFacts = RangeFacts.None; + var thisNode; if (!start || !end) { // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -158923,7 +159528,7 @@ var ts; // the expression. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. @@ -158935,7 +159540,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -158978,20 +159583,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -159015,7 +159620,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -159024,9 +159629,17 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); + if (rangeFacts & RangeFacts.UsesThis) { + var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { + rangeFacts |= RangeFacts.UsesThisInFunction; + } + } return errors; function visit(node) { if (errors) { @@ -159034,8 +159647,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -159046,16 +159659,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -159065,13 +159678,15 @@ var ts; } else { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) { return false; @@ -159081,63 +159696,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps = 0 /* PermittedJumps.None */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; + thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -159146,21 +159762,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -159183,7 +159799,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -159215,7 +159831,7 @@ var ts; */ function collectEnclosingScopes(range) { var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range; - if (range.facts & RangeFacts.UsesThis) { + if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class var containingClass = ts.getContainingClass(current); if (containingClass) { @@ -159229,7 +159845,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -159240,7 +159856,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -159280,11 +159896,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -159330,34 +159946,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -159388,7 +160004,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -159397,7 +160013,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -159416,27 +160032,37 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); var newFunction; + var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { + if (callThis) { + parameters.unshift(ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ "this", + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), + /*initializer*/ undefined)); + } newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -159451,10 +160077,13 @@ var ts; var newNodes = []; // replace range with function call var called = getCalledExpression(scope, range, functionNameText); - var call = ts.factory.createCallExpression(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference + if (callThis) { + callArguments.unshift(ts.factory.createIdentifier("this")); + } + var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -159488,7 +160117,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -159499,7 +160128,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -159514,8 +160143,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -159524,7 +160153,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -159581,9 +160210,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -159596,13 +160225,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -159610,11 +160239,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -159646,16 +160275,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -159665,7 +160294,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -159692,7 +160321,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -159711,7 +160340,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -159721,7 +160350,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -159734,10 +160363,10 @@ var ts; /* decorators */ undefined, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -159984,7 +160613,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -160062,14 +160691,17 @@ var ts; var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes)); } + if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) { + functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod)); + } var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -160113,7 +160745,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -160123,11 +160755,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -160201,7 +160833,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -160228,7 +160860,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -160309,30 +160941,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -160478,7 +161110,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -160509,7 +161141,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -160521,7 +161153,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -160547,7 +161179,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -160731,11 +161363,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -160775,7 +161407,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -160831,25 +161463,25 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -160867,21 +161499,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -160907,7 +161539,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -160931,7 +161563,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -160951,19 +161583,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -160972,7 +161604,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -160984,7 +161616,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -160997,14 +161629,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -161046,7 +161678,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -161063,7 +161695,7 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } function getNewModuleName(movedSymbols) { @@ -161073,7 +161705,7 @@ var ts; var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -161107,7 +161739,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -161125,7 +161757,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -161134,14 +161766,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -161153,7 +161785,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -161163,18 +161795,18 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -161184,11 +161816,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -161245,13 +161877,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -161259,19 +161891,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -161279,13 +161911,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -161293,9 +161925,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -161317,7 +161949,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -161325,28 +161957,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], d.modifiers); switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -161354,26 +161986,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -161436,14 +162068,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -161577,7 +162209,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -161676,7 +162308,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -161706,15 +162338,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -161724,7 +162356,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -161743,14 +162375,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -161762,7 +162394,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -161796,16 +162428,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -161813,8 +162445,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -161824,7 +162456,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -161930,7 +162562,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -161939,7 +162571,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -161964,15 +162596,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -161983,30 +162615,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -162087,16 +162719,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -162114,7 +162746,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -162127,7 +162759,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -162136,7 +162768,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -162228,8 +162860,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -162424,7 +163056,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -162450,7 +163082,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -162510,13 +163142,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -162526,7 +163158,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -162537,17 +163169,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -162574,20 +163206,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -162649,8 +163281,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -162661,7 +163293,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -162709,19 +163341,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -162738,9 +163370,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -162780,7 +163412,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -162832,12 +163464,12 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -162854,12 +163486,12 @@ var ts; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -162883,7 +163515,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -162895,7 +163527,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -162910,7 +163542,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -162932,16 +163564,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -162962,41 +163594,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -163060,7 +163692,7 @@ var ts; var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -163087,7 +163719,7 @@ var ts; var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -163108,7 +163740,7 @@ var ts; var _a; if (ts.hasStaticModifier(declaration)) return; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) { @@ -163120,7 +163752,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -163179,10 +163811,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -163202,31 +163834,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -163237,12 +163869,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -163255,7 +163887,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -163267,7 +163899,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -163276,8 +163908,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -163346,8 +163978,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -163366,7 +163998,7 @@ var ts; this.fileNameToEntry = new ts.Map(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "initializeHostCache", { count: rootFileNames.length }); for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); @@ -163436,7 +164068,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -163533,7 +164165,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -163563,7 +164195,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -163653,7 +164285,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -163773,7 +164405,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -163963,8 +164595,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -163997,27 +164629,27 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; } } /// Goto definition - function getDefinitionAtPosition(fileName, position) { + function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly, stopAtAlias) { synchronizeHostData(); - return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); + return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias); } function getDefinitionAndBoundSpan(fileName, position) { synchronizeHostData(); @@ -164034,7 +164666,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -164058,17 +164690,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -164115,16 +164747,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -164140,7 +164772,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -164170,8 +164802,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -164180,8 +164812,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -164202,10 +164834,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -164302,7 +164934,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -164311,15 +164943,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -164329,12 +164961,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -164431,14 +165063,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -164448,7 +165080,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -164534,10 +165166,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -164552,12 +165184,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -164675,9 +165307,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -164833,14 +165465,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -164887,7 +165519,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -164902,16 +165534,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -164953,7 +165585,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -165000,7 +165632,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -165033,144 +165665,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.decorators); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -165182,14 +165814,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -165198,35 +165830,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -165235,21 +165867,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -165257,7 +165889,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -165287,7 +165919,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -165298,8 +165930,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if (variableDeclaration.initializer || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -165314,7 +165946,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -165339,8 +165971,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -165363,26 +165995,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -165407,21 +166039,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -165429,18 +166061,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -165448,25 +166080,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -165474,7 +166106,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -165490,7 +166122,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -165505,12 +166137,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -165519,21 +166151,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -165543,20 +166175,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -165564,7 +166196,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -165732,7 +166364,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -165822,13 +166454,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -165910,7 +166542,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -165926,43 +166558,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -165978,7 +166610,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -165987,7 +166619,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -165995,12 +166627,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -166009,7 +166641,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -166017,7 +166649,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -166026,7 +166658,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -166035,37 +166667,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, options); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -166073,23 +166705,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -166104,108 +166736,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -166255,11 +166887,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -166270,7 +166902,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -166282,7 +166914,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -166297,7 +166929,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -166319,7 +166951,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -166519,7 +167151,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -166530,7 +167162,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -166583,7 +167215,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -166656,7 +167288,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -166670,7 +167302,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -166679,7 +167311,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -166701,7 +167333,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -166729,7 +167361,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -166745,7 +167377,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -166764,12 +167396,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -166795,7 +167427,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -166823,16 +167455,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -166840,20 +167472,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -166864,17 +167496,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -166926,7 +167558,7 @@ var ts; } Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + throw new Error("Project '".concat(project.getProjectName(), "' does not contain document '").concat(fileName, "'")); } Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; })(Errors = server.Errors || (server.Errors = {})); @@ -166967,14 +167599,19 @@ var ts; } server.isInferredProjectName = isInferredProjectName; function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; + return "/dev/null/inferredProject".concat(counter, "*"); } server.makeInferredProjectName = makeInferredProjectName; /*@internal*/ function makeAutoImportProviderProjectName(counter) { - return "/dev/null/autoImportProviderProject" + counter + "*"; + return "/dev/null/autoImportProviderProject".concat(counter, "*"); } server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName; + /*@internal*/ + function makeAuxiliaryProjectName(counter) { + return "/dev/null/auxiliaryProject".concat(counter, "*"); + } + server.makeAuxiliaryProjectName = makeAuxiliaryProjectName; function createSortedArray() { return []; // TODO: GH#19873 } @@ -167007,7 +167644,7 @@ var ts; // schedule new operation, pass arguments this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); if (this.logger) { - this.logger.info("Scheduled: " + operationId + (pendingTimeout ? ", Cancelled earlier one" : "")); + this.logger.info("Scheduled: ".concat(operationId).concat(pendingTimeout ? ", Cancelled earlier one" : "")); } }; ThrottledOperations.prototype.cancel = function (operationId) { @@ -167021,7 +167658,7 @@ var ts; ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { - self.logger.info("Running: " + operationId); + self.logger.info("Running: ".concat(operationId)); } cb(); ts.perfLogger.logStopScheduledOperation(); @@ -167050,7 +167687,7 @@ var ts; self.host.gc(); // TODO: GH#18217 if (log) { var after = self.host.getMemoryUsage(); // TODO: GH#18217 - self.logger.perftrc("GC::before " + before + ", after " + after); + self.logger.perftrc("GC::before ".concat(before, ", after ").concat(after)); } ts.perfLogger.logStopScheduledOperation(); }; @@ -167188,6 +167825,7 @@ var ts; CommandTypes["SignatureHelp"] = "signatureHelp"; /* @internal */ CommandTypes["SignatureHelpFull"] = "signatureHelp-full"; + CommandTypes["FindSourceDefinition"] = "findSourceDefinition"; CommandTypes["Status"] = "status"; CommandTypes["TypeDefinition"] = "typeDefinition"; CommandTypes["ProjectInfo"] = "projectInfo"; @@ -167403,8 +168041,8 @@ var ts; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.version.svc + "-" + this.svc.getSnapshotVersion() - : "Text-" + this.version.text; + ? "SVC-".concat(this.version.svc, "-").concat(this.svc.getSnapshotVersion()) + : "Text-".concat(this.version.text); }; TextStorage.prototype.hasScriptVersionCache_TestOnly = function () { return this.svc !== undefined; @@ -167547,7 +168185,7 @@ var ts; if (fileSize > server.maxFileSize) { ts.Debug.assert(!!this.info.containingProjects.length); var service = this.info.containingProjects[0].projectService; - service.logger.info("Skipped loading contents of large file " + fileName + " for info " + this.info.fileName + ": fileSize: " + fileSize); + service.logger.info("Skipped loading contents of large file ".concat(fileName, " for info ").concat(this.info.fileName, ": fileSize: ").concat(fileSize)); this.info.containingProjects[0].projectService.sendLargeFileReferencedEvent(fileName, fileSize); return { text: "", fileSize: fileSize }; } @@ -167767,7 +168405,7 @@ var ts; case 0: return server.Errors.ThrowNoProject(); case 1: - return ensureNotAutoImportProvider(this.containingProjects[0]); + return ensurePrimaryProjectKind(this.containingProjects[0]); default: // If this file belongs to multiple projects, below is the order in which default project is used // - for open script info, its default configured project during opening is default if info is part of it @@ -167805,7 +168443,7 @@ var ts; firstInferredProject = project; } } - return ensureNotAutoImportProvider(defaultConfiguredProject || + return ensurePrimaryProjectKind(defaultConfiguredProject || firstNonSourceOfProjectReferenceRedirect || firstConfiguredProject || firstExternalProject || @@ -167881,8 +168519,8 @@ var ts; return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); }); }; /*@internal*/ - ScriptInfo.prototype.isContainedByAutoImportProvider = function () { - return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; }); + ScriptInfo.prototype.isContainedByBackgroundProject = function () { + return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; }); }; /** * @param line 1 based index @@ -167900,7 +168538,7 @@ var ts; return location; }; ScriptInfo.prototype.isJavaScript = function () { - return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */; + return this.scriptKind === 1 /* ScriptKind.JS */ || this.scriptKind === 2 /* ScriptKind.JSX */; }; /*@internal*/ ScriptInfo.prototype.getLineInfo = function () { @@ -167916,21 +168554,26 @@ var ts; return ScriptInfo; }()); server.ScriptInfo = ScriptInfo; - function ensureNotAutoImportProvider(project) { - if (!project || project.projectKind === server.ProjectKind.AutoImportProvider) { + /** + * Throws an error if `project` is an AutoImportProvider or AuxiliaryProject, + * which are used in the background by other Projects and should never be + * reported as the default project for a ScriptInfo. + */ + function ensurePrimaryProjectKind(project) { + if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) { return server.Errors.ThrowNoProject(); } return project; } function failIfInvalidPosition(position) { - ts.Debug.assert(typeof position === "number", "Expected position " + position + " to be a number."); + ts.Debug.assert(typeof position === "number", "Expected position ".concat(position, " to be a number.")); ts.Debug.assert(position >= 0, "Expected position to be non-negative."); } function failIfInvalidLocation(location) { - ts.Debug.assert(typeof location.line === "number", "Expected line " + location.line + " to be a number."); - ts.Debug.assert(typeof location.offset === "number", "Expected offset " + location.offset + " to be a number."); - ts.Debug.assert(location.line > 0, "Expected line to be non-" + (location.line === 0 ? "zero" : "negative")); - ts.Debug.assert(location.offset > 0, "Expected offset to be non-" + (location.offset === 0 ? "zero" : "negative")); + ts.Debug.assert(typeof location.line === "number", "Expected line ".concat(location.line, " to be a number.")); + ts.Debug.assert(typeof location.offset === "number", "Expected offset ".concat(location.offset, " to be a number.")); + ts.Debug.assert(location.line > 0, "Expected line to be non-".concat(location.line === 0 ? "zero" : "negative")); + ts.Debug.assert(location.offset > 0, "Expected offset to be non-".concat(location.offset === 0 ? "zero" : "negative")); } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -168057,6 +168700,7 @@ var ts; ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; ProjectKind[ProjectKind["External"] = 2] = "External"; ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider"; + ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary"; })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); /* @internal */ function countEachFileTypes(infos, includeSizes) { @@ -168073,16 +168717,16 @@ var ts; var info = infos_1[_i]; var fileSize = includeSizes ? info.getTelemetryFileSize() : 0; switch (info.scriptKind) { - case 1 /* JS */: + case 1 /* ScriptKind.JS */: result.js += 1; result.jsSize += fileSize; break; - case 2 /* JSX */: + case 2 /* ScriptKind.JSX */: result.jsx += 1; result.jsxSize += fileSize; break; - case 3 /* TS */: - if (ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */)) { + case 3 /* ScriptKind.TS */: + if (ts.isDeclarationFileName(info.fileName)) { result.dts += 1; result.dtsSize += fileSize; } @@ -168091,11 +168735,11 @@ var ts; result.tsSize += fileSize; } break; - case 4 /* TSX */: + case 4 /* ScriptKind.TSX */: result.tsx += 1; result.tsxSize += fileSize; break; - case 7 /* Deferred */: + case 7 /* ScriptKind.Deferred */: result.deferred += 1; result.deferredSize += fileSize; break; @@ -168120,7 +168764,7 @@ var ts; server.allFilesAreJsOrDts = allFilesAreJsOrDts; /* @internal */ function hasNoTypeScriptSource(fileNames) { - return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); }); + return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Extension.Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Extension.Tsx */); }); } server.hasNoTypeScriptSource = hasNoTypeScriptSource; function isGeneratedFileWatcher(watch) { @@ -168242,11 +168886,11 @@ var ts; }; Project.resolveModule = function (moduleName, initialDir, host, log, logErrors) { var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); - log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + log("Loading ".concat(moduleName, " from ").concat(initialDir, " (resolved to ").concat(resolvedPath, ")")); var result = host.require(resolvedPath, moduleName); // TODO: GH#18217 if (result.error) { var err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)("Failed to load module '" + moduleName + "' from " + resolvedPath + ": " + err); + (logErrors || log)("Failed to load module '".concat(moduleName, "' from ").concat(resolvedPath, ": ").concat(err)); return undefined; } return result.module; @@ -168397,12 +169041,12 @@ var ts; }; /*@internal*/ Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () { - return this.projectService.throttledOperations.cancel(this.getProjectName() + "FailedLookupInvalidation"); + return this.projectService.throttledOperations.cancel("".concat(this.getProjectName(), "FailedLookupInvalidation")); }; /*@internal*/ Project.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { var _this = this; - this.projectService.throttledOperations.schedule(this.getProjectName() + "FailedLookupInvalidation", /*delay*/ 1000, function () { + this.projectService.throttledOperations.schedule("".concat(this.getProjectName(), "FailedLookupInvalidation"), /*delay*/ 1000, function () { if (_this.resolutionCache.invalidateResolutionsOfFailedLookupLocations()) { _this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(_this); } @@ -168524,7 +169168,7 @@ var ts; } // Update the signature if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) { - var dtsFiles = outputFiles.filter(function (f) { return ts.fileExtensionIs(f.name, ".d.ts" /* Dts */); }); + var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); }); if (dtsFiles.length === 1) { var sourceFile = this.program.getSourceFile(scriptInfo.fileName); var signature = this.projectService.host.createHash ? @@ -168580,7 +169224,7 @@ var ts; return plugin.module.getExternalFiles(_this); } catch (e) { - _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: ".concat(e)); if (e.stack) { _this.projectService.logger.info(e.stack); } @@ -168643,6 +169287,10 @@ var ts; this.autoImportProviderHost.close(); } this.autoImportProviderHost = undefined; + if (this.noDtsResolutionProject) { + this.noDtsResolutionProject.close(); + } + this.noDtsResolutionProject = undefined; // signal language service to release source files acquired from document registry this.languageService.dispose(); this.languageService = undefined; @@ -168683,7 +169331,7 @@ var ts; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.resolvedPath); - ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' / '" + sourceFile.resolvedPath + "' is missing."; }); + ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '".concat(sourceFile.fileName, "' Path: '").concat(sourceFile.path, "' / '").concat(sourceFile.resolvedPath, "' is missing."); }); return scriptInfo; }); }; @@ -168857,7 +169505,7 @@ var ts; */ Project.prototype.updateGraph = function () { var _a; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); @@ -168928,13 +169576,13 @@ var ts; var _this = this; var oldProgram = this.program; ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project"); - this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName()); + this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName())); var start = ts.timestamp(); this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution"); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "finishCachingPerDirectoryResolution"); this.resolutionCache.finishCachingPerDirectoryResolution(); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); ts.Debug.assert(oldProgram === undefined || this.program !== undefined); @@ -168942,7 +169590,7 @@ var ts; // - oldProgram is not set - this is a first time updateGraph is called // - newProgram is different from the old program and structure of the old program was not reused. var hasNewProgram = false; - if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) { + if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* StructureIsReused.Completely */))) { hasNewProgram = true; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { @@ -168968,7 +169616,7 @@ var ts; var outPath = ts.outFile(this.compilerOptions); if (isGeneratedFileWatcher(this.generatedFilesMap)) { // --out - if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Dts */, this.generatedFilesMap)) { + if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */, this.generatedFilesMap)) { this.clearGeneratedFileWatch(); } } @@ -169032,7 +169680,7 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.sendPerformanceEvent("UpdateGraph", elapsed); - this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + (this.program ? " structureIsReused:: " + ts.StructureIsReused[this.program.structureIsReused] : "") + " Elapsed: " + elapsed + "ms"); + this.writeLog("Finishing updateGraphWorker: Project: ".concat(this.getProjectName(), " Version: ").concat(this.getProjectVersion(), " structureChanged: ").concat(hasNewProgram).concat(this.program ? " structureIsReused:: ".concat(ts.StructureIsReused[this.program.structureIsReused]) : "", " Elapsed: ").concat(elapsed, "ms")); if (this.hasAddedorRemovedFiles) { this.print(/*writeProjectFileNames*/ true); } @@ -169092,7 +169740,7 @@ var ts; var path = this.toPath(sourceFile); if (this.generatedFilesMap) { if (isGeneratedFileWatcher(this.generatedFilesMap)) { - ts.Debug.fail(this.projectName + " Expected to not have --out watcher for generated file with options: " + JSON.stringify(this.compilerOptions)); + ts.Debug.fail("".concat(this.projectName, " Expected to not have --out watcher for generated file with options: ").concat(JSON.stringify(this.compilerOptions))); return; } if (this.generatedFilesMap.has(path)) @@ -169144,20 +169792,20 @@ var ts; if (!this.program) return "\tFiles (0) NoProgram\n"; var sourceFiles = this.program.getSourceFiles(); - var strBuilder = "\tFiles (" + sourceFiles.length + ")\n"; + var strBuilder = "\tFiles (".concat(sourceFiles.length, ")\n"); if (writeProjectFileNames) { for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var file = sourceFiles_1[_i]; - strBuilder += "\t" + file.fileName + "\n"; + strBuilder += "\t".concat(file.fileName, "\n"); } strBuilder += "\n\n"; - ts.explainFiles(this.program, function (s) { return strBuilder += "\t" + s + "\n"; }); + ts.explainFiles(this.program, function (s) { return strBuilder += "\t".concat(s, "\n"); }); } return strBuilder; }; /*@internal*/ Project.prototype.print = function (writeProjectFileNames) { - this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ")"); + this.writeLog("Project '".concat(this.projectName, "' (").concat(ProjectKind[this.projectKind], ")")); this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(server.LogLevel.verbose))); this.writeLog("-----------------------------------------------"); if (this.autoImportProviderHost) { @@ -169165,11 +169813,13 @@ var ts; } }; Project.prototype.setCompilerOptions = function (compilerOptions) { + var _a; if (compilerOptions) { compilerOptions.allowNonTsExtensions = true; var oldOptions = this.compilerOptions; this.compilerOptions = compilerOptions; this.setInternalCompilerOptionsForEmittingJsFiles(); + (_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject()); if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) { // reset cached unresolved imports if changes in compiler options affected module resolution this.cachedUnresolvedImportsPerFile.clear(); @@ -169319,7 +169969,7 @@ var ts; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; // Provide global: true so plugins can detect why they can't find their config - this_1.projectService.logger.info("Loading global plugin " + globalPluginName); + this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName)); this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; @@ -169332,9 +169982,9 @@ var ts; }; Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; - this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); + this.projectService.logger.info("Enabling plugin ".concat(pluginConfigEntry.name, " from candidate paths: ").concat(searchPaths.join(","))); if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) { - this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name"); + this.projectService.logger.info("Skipped loading plugin ".concat(pluginConfigEntry.name || JSON.stringify(pluginConfigEntry), " because only package name is allowed plugin name")); return; } var log = function (message) { return _this.projectService.logger.info(message); }; @@ -169357,13 +170007,13 @@ var ts; } else { ts.forEach(errorLogs, log); - this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); + this.projectService.logger.info("Couldn't find ".concat(pluginConfigEntry.name)); } }; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin ".concat(configEntry.name, " because it did not expose a proper factory function")); return; } var info = { @@ -169380,7 +170030,7 @@ var ts; var k = _a[_i]; // eslint-disable-next-line no-in-operator if (!(k in newLS)) { - this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); + this.projectService.logger.info("Plugin activation warning: Missing proxied method ".concat(k, " in created LS. Patching.")); newLS[k] = this.languageService[k]; } } @@ -169389,7 +170039,7 @@ var ts; this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { - this.projectService.logger.info("Plugin activation failed: " + e); + this.projectService.logger.info("Plugin activation failed: ".concat(e)); } }; /*@internal*/ @@ -169439,11 +170089,11 @@ var ts; }; /*@internal*/ Project.prototype.includePackageJsonAutoImports = function () { - if (this.projectService.includePackageJsonAutoImports() === 0 /* Off */ || + if (this.projectService.includePackageJsonAutoImports() === 0 /* PackageJsonAutoImportPreference.Off */ || !this.languageServiceEnabled || ts.isInsideNodeModules(this.currentDirectory) || !this.isDefaultProjectForOpenFiles()) { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; } return this.projectService.includePackageJsonAutoImports(); }; @@ -169484,7 +170134,7 @@ var ts; } var dependencySelection = this.includePackageJsonAutoImports(); if (dependencySelection) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider"); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getPackageJsonAutoImportProvider"); var start = ts.timestamp(); this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry); if (this.autoImportProviderHost) { @@ -169509,12 +170159,37 @@ var ts; Project.prototype.getIncompleteCompletionsCache = function () { return this.projectService.getIncompleteCompletionsCache(); }; + /*@internal*/ + Project.prototype.getNoDtsResolutionProject = function (rootFileNames) { + var _this = this; + ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic); + if (!this.noDtsResolutionProject) { + this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject()); + } + ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) { + var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost); + if (info) { + _this.noDtsResolutionProject.addRoot(info, pathToAdd); + } + }, function (pathToRemove) { + // It may be preferable to remove roots only once project grows to a certain size? + var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove); + if (info) { + _this.noDtsResolutionProject.removeRoot(info); + } + }); + return this.noDtsResolutionProject; + }; + /*@internal*/ + Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () { + return __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true }); + }; return Project; }()); server.Project = Project; function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) { var sourceFiles = program.getSourceFiles(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getUnresolvedImports", { count: sourceFiles.length }); var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) { return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile); @@ -169624,6 +170299,26 @@ var ts; return InferredProject; }(Project)); server.InferredProject = InferredProject; + var AuxiliaryProject = /** @class */ (function (_super) { + __extends(AuxiliaryProject, _super); + function AuxiliaryProject(projectService, documentRegistry, compilerOptions) { + return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry, + /*hasExplicitListOfFiles*/ false, + /*lastFileExceededProgramSize*/ undefined, compilerOptions, + /*compileOnSaveEnabled*/ false, + /*watchOptions*/ undefined, projectService.host, + /*currentDirectory*/ undefined) || this; + } + AuxiliaryProject.prototype.isOrphan = function () { + return true; + }; + /*@internal*/ + AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { + // Invalidation will happen on-demand as part of updateGraph + return; + }; + return AuxiliaryProject; + }(Project)); var AutoImportProviderProject = /** @class */ (function (_super) { __extends(AutoImportProviderProject, _super); /*@internal*/ @@ -169663,8 +170358,8 @@ var ts; var symlinkCache_1 = hostProject.getSymlinkCache(); var _loop_2 = function (name) { // Avoid creating a large project that would significantly slow down time to editor interactivity - if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this_2.maxDependencies) { - hostProject.log("AutoImportProviderProject: attempted to add more than " + this_2.maxDependencies + " dependencies. Aborting."); + if (dependencySelection === 2 /* PackageJsonAutoImportPreference.Auto */ && dependenciesAdded > this_2.maxDependencies) { + hostProject.log("AutoImportProviderProject: attempted to add more than ".concat(this_2.maxDependencies, " dependencies. Aborting.")); return { value: ts.emptyArray }; } // 1. Try to load from the implementation package. For many dependencies, the @@ -169684,7 +170379,7 @@ var ts; // typings cache location, if enabled. var done = ts.forEach([hostProject.currentDirectory, hostProject.getGlobalTypingsCacheLocation()], function (directory) { if (directory) { - var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); + var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/".concat(name), directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); if (typesPackageJson) { var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache_1); rootNames = ts.concatenate(rootNames, entrypoints); @@ -169713,7 +170408,7 @@ var ts; } } if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) { - hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms"); + hostProject.log("AutoImportProviderProject: found ".concat(rootNames.length, " root files in ").concat(dependenciesAdded, " dependencies in ").concat(ts.timestamp() - start, " ms")); } return rootNames || ts.emptyArray; function addDependency(dependency) { @@ -169744,7 +170439,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) { - if (dependencySelection === 0 /* Off */) { + if (dependencySelection === 0 /* PackageJsonAutoImportPreference.Off */) { return undefined; } var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), this.compilerOptionsOverrides); @@ -169775,6 +170470,11 @@ var ts; } return hasSameSetOfFiles; }; + /*@internal*/ + AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { + // Invalidation will happen on-demand as part of updateGraph + return; + }; AutoImportProviderProject.prototype.hasRoots = function () { var _a; return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length); @@ -169805,7 +170505,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.prototype.includePackageJsonAutoImports = function () { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; }; AutoImportProviderProject.prototype.getTypeAcquisition = function () { return { enable: false }; @@ -169970,7 +170670,7 @@ var ts; var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); - this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); + this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths")); searchPaths.unshift(local); } // Enable tsconfig-specified plugins @@ -170249,15 +170949,15 @@ var ts; function convertScriptKindName(scriptKindName) { switch (scriptKindName) { case "JS": - return 1 /* JS */; + return 1 /* ScriptKind.JS */; case "JSX": - return 2 /* JSX */; + return 2 /* ScriptKind.JSX */; case "TS": - return 3 /* TS */; + return 3 /* ScriptKind.TS */; case "TSX": - return 4 /* TSX */; + return 4 /* ScriptKind.TSX */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } server.convertScriptKindName = convertScriptKindName; @@ -170396,7 +171096,7 @@ var ts; return forEachAnyProjectReferenceKind(project, function (resolvedRef) { return callbackRefProject(project, cb, resolvedRef.sourceFile.path); }, function (projectRef) { return callbackRefProject(project, cb, project.toPath(ts.resolveProjectReferencePath(projectRef))); }, function (potentialProjectRef) { return callbackRefProject(project, cb, potentialProjectRef); }); } function getDetailWatchInfo(watchType, project) { - return (ts.isString(project) ? "Config: " + project + " " : project ? "Project: " + project.getProjectName() + " " : "") + "WatchType: " + watchType; + return "".concat(ts.isString(project) ? "Config: ".concat(project, " ") : project ? "Project: ".concat(project.getProjectName(), " ") : "", "WatchType: ").concat(watchType); } function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; @@ -170460,6 +171160,8 @@ var ts; this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName); /*@internal*/ this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName); + /*@internal*/ + this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName); /** * Open files: with value being project root path, and key being Path of the file that is open */ @@ -170601,7 +171303,7 @@ var ts; try { var fileContent = this.host.readFile(this.typesMapLocation); // TODO: GH#18217 if (fileContent === undefined) { - this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); + this.logger.info("Provided types map file \"".concat(this.typesMapLocation, "\" doesn't exist")); return; } var raw = JSON.parse(fileContent); @@ -170619,7 +171321,7 @@ var ts; } } catch (e) { - this.logger.info("Error loading types map: " + e); + this.logger.info("Error loading types map: ".concat(e)); this.safelist = defaultTypeSafeList; this.legacySafelist.clear(); } @@ -170663,13 +171365,15 @@ var ts; ProjectService.prototype.delayUpdateProjectGraph = function (project) { var _this = this; project.markAsDirty(); - var projectName = project.getProjectName(); - this.pendingProjectUpdates.set(projectName, project); - this.throttledOperations.schedule(projectName, /*delay*/ 250, function () { - if (_this.pendingProjectUpdates.delete(projectName)) { - updateProjectIfDirty(project); - } - }); + if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) { + var projectName_1 = project.getProjectName(); + this.pendingProjectUpdates.set(projectName_1, project); + this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () { + if (_this.pendingProjectUpdates.delete(projectName_1)) { + updateProjectIfDirty(project); + } + }); + } }; /*@internal*/ ProjectService.prototype.hasPendingProjectUpdate = function (project) { @@ -170941,7 +171645,7 @@ var ts; var fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { - _this.logger.info("Config: " + configFileName + " Detected new package.json: " + fileOrDirectory); + _this.logger.info("Config: ".concat(configFileName, " Detected new package.json: ").concat(fileOrDirectory)); _this.onAddPackageJson(fileOrDirectoryPath); } var configuredProjectForConfig = _this.findConfiguredProjectByProjectName(configFileName); @@ -171063,14 +171767,14 @@ var ts; this.logger.info("`remove Project::"); project.print(/*writeProjectFileNames*/ true); project.close(); - if (ts.Debug.shouldAssert(1 /* Normal */)) { - this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? + if (ts.Debug.shouldAssert(1 /* AssertionLevel.Normal */)) { + this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return "".concat(project.projectName, ": ScriptInfos still attached: ").concat(JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? { fileName: info.fileName, projects: info.containingProjects.map(function (p) { return p.projectName; }), hasMixedContent: info.hasMixedContent } : undefined; })), - /*replacer*/ undefined, " "); }); }); + /*replacer*/ undefined, " ")); }); }); } // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); @@ -171471,15 +172175,15 @@ var ts; if (result !== undefined) return result || undefined; } - this.logger.info("Search path: " + ts.getDirectoryPath(info.fileName)); + this.logger.info("Search path: ".concat(ts.getDirectoryPath(info.fileName))); var configFileName = this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { return _this.configFileExists(configFileName, canonicalConfigFilePath, info); }); if (configFileName) { - this.logger.info("For info: " + info.fileName + " :: Config file name: " + configFileName); + this.logger.info("For info: ".concat(info.fileName, " :: Config file name: ").concat(configFileName)); } else { - this.logger.info("For info: " + info.fileName + " :: No config files found."); + this.logger.info("For info: ".concat(info.fileName, " :: No config files found.")); } if (isOpenScriptInfo(info)) { this.configFileForOpenFiles.set(info.path, configFileName || false); @@ -171498,8 +172202,8 @@ var ts; this.logger.info("Open files: "); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); - _this.logger.info("\tFileName: " + info.fileName + " ProjectRootPath: " + projectRootPath); - _this.logger.info("\t\tProjects: " + info.containingProjects.map(function (p) { return p.getProjectName(); })); + _this.logger.info("\tFileName: ".concat(info.fileName, " ProjectRootPath: ").concat(projectRootPath)); + _this.logger.info("\t\tProjects: ".concat(info.containingProjects.map(function (p) { return p.getProjectName(); }))); }); this.logger.endGroup(); }; @@ -171538,7 +172242,7 @@ var ts; .map(function (name) { return ({ name: name, size: _this.host.getFileSize(name) }); }) .sort(function (a, b) { return b.size - a.size; }) .slice(0, 5); - this.logger.info("Non TS file size exceeded limit (" + totalNonTsFileSize + "). Largest files: " + top5LargestFiles.map(function (file) { return file.name + ":" + file.size; }).join(", ")); + this.logger.info("Non TS file size exceeded limit (".concat(totalNonTsFileSize, "). Largest files: ").concat(top5LargestFiles.map(function (file) { return "".concat(file.name, ":").concat(file.size); }).join(", "))); // Keep the size as zero since it's disabled return fileName; } @@ -171607,8 +172311,8 @@ var ts; }; /* @internal */ ProjectService.prototype.createConfiguredProject = function (configFileName) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName }); - this.logger.info("Creating configuration project " + configFileName); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "createConfiguredProject", { configFilePath: configFileName }); + this.logger.info("Creating configuration project ".concat(configFileName)); var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); // We could be in this scenario if project is the configured project tracked by external project @@ -171656,7 +172360,7 @@ var ts; /* @internal */ ProjectService.prototype.loadConfiguredProject = function (project, reason) { var _this = this; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); this.sendProjectLoadingStartEvent(project, reason); // Read updated contents from disk var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath())); @@ -171721,12 +172425,12 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } - this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + this.logger.info("Config: ".concat(configFilename, " : ").concat(JSON.stringify({ rootNames: parsedCommandLine.fileNames, options: parsedCommandLine.options, watchOptions: parsedCommandLine.watchOptions, projectReferences: parsedCommandLine.projectReferences - }, /*replacer*/ undefined, " ")); + }, /*replacer*/ undefined, " "))); var oldCommandLine = (_b = configFileExistenceInfo.config) === null || _b === void 0 ? void 0 : _b.parsedCommandLine; if (!configFileExistenceInfo.config) { configFileExistenceInfo.config = { parsedCommandLine: parsedCommandLine, cachedDirectoryStructureHost: cachedDirectoryStructureHost, projects: new ts.Map() }; @@ -171756,7 +172460,7 @@ var ts; // Update projects var ensureProjectsForOpenFiles = false; (_a = _this.sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (canonicalPath) { - ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file " + extendedConfigFileName + " detected") || ensureProjectsForOpenFiles; + ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file ".concat(extendedConfigFileName, " detected")) || ensureProjectsForOpenFiles; }); if (ensureProjectsForOpenFiles) _this.delayEnsureProjectForOpenFiles(); @@ -171912,7 +172616,7 @@ var ts; // Clear the cache since we are reloading the project from disk host.clearCache(); var configFileName = project.getConfigFilePath(); - this.logger.info((isInitialLoad ? "Loading" : "Reloading") + " configured project " + configFileName); + this.logger.info("".concat(isInitialLoad ? "Loading" : "Reloading", " configured project ").concat(configFileName)); // Load project from the disk this.loadConfiguredProject(project, reason); project.updateGraph(); @@ -172051,7 +172755,7 @@ var ts; var path = _a[0], scriptInfo = _a[1]; return ({ path: path, fileName: scriptInfo.fileName }); }); - this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); + this.logger.msg("Could not find file ".concat(JSON.stringify(fileName), ".\nAll files are: ").concat(JSON.stringify(names)), server.Msg.Err); }; /** * Returns the projects that contain script info through SymLink @@ -172144,7 +172848,7 @@ var ts; } } } - }, 1 /* Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); + }, 1 /* WatchDirectoryFlags.Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); var result = { refreshScriptInfoRefCount: 0, affectedModuleSpecifierCacheProjects: undefined, @@ -172235,9 +172939,9 @@ var ts; var info = this.getScriptInfoForPath(path); if (!info) { var isDynamic = server.isDynamicFileName(fileName); - ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); - ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); - ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."; }); + ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"); }); + ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"); }); + ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."); }); // If the file is not opened by client and the file doesnot exist on the disk, return if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; @@ -172416,13 +173120,13 @@ var ts; var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); if (info) { info.setOptions(convertFormatOptions(args.formatOptions), args.preferences); - this.logger.info("Host configuration update for file " + args.file); + this.logger.info("Host configuration update for file ".concat(args.file)); } } else { if (args.hostInfo !== undefined) { this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); + this.logger.info("Host information ".concat(args.hostInfo)); } if (args.formatOptions) { this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); @@ -172454,7 +173158,7 @@ var ts; } if (args.watchOptions) { this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions; - this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches."); + this.logger.info("Host watch options changed to ".concat(JSON.stringify(this.hostConfiguration.watchOptions), ", it will be take effect for next watches.")); } } }; @@ -172666,7 +173370,7 @@ var ts; ? originalLocation : location; } - configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: ".concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); } updateProjectIfDirty(configuredProject); var projectContainsOriginalInfo = function (project) { @@ -172678,7 +173382,7 @@ var ts; configuredProject = forEachResolvedProjectReferenceProject(configuredProject, fileName, function (child) { updateProjectIfDirty(child); return projectContainsOriginalInfo(child) ? child : undefined; - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + configuredProject.projectName + " to find possible configured project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(configuredProject.projectName, " to find possible configured project for original file: ").concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); if (!configuredProject) return undefined; if (configuredProject === project) @@ -172732,7 +173436,7 @@ var ts; if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { - project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for " + info.fileName + " to open"); + project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for ".concat(info.fileName, " to open")); defaultConfigProjectIsCreated = true; } else { @@ -172762,7 +173466,7 @@ var ts; if (!projectForConfigFileDiag && child.containsScriptInfo(info)) { projectForConfigFileDiag = child; } - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + project.projectName + " to find possible configured project for " + info.fileName + " to open"); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(project.projectName, " to find possible configured project for ").concat(info.fileName, " to open")); } // Send the event only if the project got created as part of this open request and info is part of the project if (projectForConfigFileDiag) { @@ -172824,7 +173528,7 @@ var ts; return; // find or delay load the project var ancestor = this.findConfiguredProjectByProjectName(configFileName) || - this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project " + project.getProjectName() + " of open file " + info.fileName); + this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project ".concat(project.getProjectName(), " of open file ").concat(info.fileName)); if (ancestor.isInitialLoadPending()) { // Set a potential project reference ancestor.setPotentialProjectReference(project.canonicalConfigFilePath); @@ -172867,7 +173571,7 @@ var ts; // Load this project, var configFileName = server.toNormalizedPath(child.sourceFile.fileName); var childProject = project.projectService.findConfiguredProjectByProjectName(configFileName) || - project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : " + project.projectName + " as it references project " + referencedProject.sourceFile.fileName); + project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : ".concat(project.projectName, " as it references project ").concat(referencedProject.sourceFile.fileName)); updateProjectIfDirty(childProject); // Ensure children for this project this.ensureProjectChildren(childProject, forProjects, seenProjects); @@ -172950,7 +173654,7 @@ var ts; var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo); this.filenameToScriptInfo.forEach(function (info) { // If script info is open or orphan, retain it and its dependencies - if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByAutoImportProvider()) { + if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) { // Otherwise if there is any source info that is alive, this alive too if (!info.sourceMapFilePath) return; @@ -173168,7 +173872,7 @@ var ts; for (var _b = 0, normalizedNames_1 = normalizedNames; _b < normalizedNames_1.length; _b++) { var root = normalizedNames_1[_b]; if (rule.match.test(root)) { - this_3.logger.info("Excluding files based on rule " + name + " matching file '" + root + "'"); + this_3.logger.info("Excluding files based on rule ".concat(name, " matching file '").concat(root, "'")); // If the file matches, collect its types packages and exclude rules if (rule.types) { for (var _c = 0, _d = rule.types; _c < _d.length; _c++) { @@ -173193,7 +173897,7 @@ var ts; if (typeof groupNumberOrString === "number") { if (!ts.isString(groups[groupNumberOrString])) { // Specification was wrong - exclude nothing! - _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + _this.logger.info("Incorrect RegExp specification in safelist rule ".concat(name, " - not enough groups")); // * can't appear in a filename; escape it because it's feeding into a RegExp return "\\*"; } @@ -173241,7 +173945,7 @@ var ts; var cleanedTypingName = ts.removeMinAndVersionNumbers(inferredTypingName); var typeName = this_4.legacySafelist.get(cleanedTypingName); if (typeName !== undefined) { - this_4.logger.info("Excluded '" + normalizedNames[i] + "' because it matched " + cleanedTypingName + " from the legacy safelist"); + this_4.logger.info("Excluded '".concat(normalizedNames[i], "' because it matched ").concat(cleanedTypingName, " from the legacy safelist")); excludedFiles.push(normalizedNames[i]); // *exclude* it from the project... exclude = true; @@ -173371,8 +174075,8 @@ var ts; if (!project) { // errors are stored in the project, do not need to update the graph project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? - this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName) : - this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName); + this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)) : + this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)); } if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { // keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project @@ -173392,7 +174096,7 @@ var ts; ProjectService.prototype.hasDeferredExtension = function () { for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { // TODO: GH#18217 var extension = _a[_i]; - if (extension.scriptKind === 7 /* Deferred */) { + if (extension.scriptKind === 7 /* ScriptKind.Deferred */) { return true; } } @@ -173416,11 +174120,11 @@ var ts; var processDirectory = function (directory) { switch (packageJsonCache.directoryHasPackageJson(directory)) { // Sync and check same directory again - case 3 /* Maybe */: + case 3 /* Ternary.Maybe */: packageJsonCache.searchDirectoryAndAncestors(directory); return processDirectory(directory); // Check package.json - case -1 /* True */: + case -1 /* Ternary.True */: var packageJsonFileName = ts.combinePaths(directory, "package.json"); _this.watchPackageJsonFile(packageJsonFileName); var info = packageJsonCache.getInDirectory(directory); @@ -173439,9 +174143,9 @@ var ts; var _this = this; return ts.forEachAncestorDirectory(fileName, function (directory) { switch (_this.packageJsonCache.directoryHasPackageJson(_this.toPath(directory))) { - case -1 /* True */: return directory; - case 0 /* False */: return undefined; - case 3 /* Maybe */: + case -1 /* Ternary.True */: return directory; + case 0 /* Ternary.False */: return undefined; + case 3 /* Ternary.Maybe */: return _this.host.fileExists(ts.combinePaths(directory, "package.json")) ? directory : undefined; @@ -173480,9 +174184,9 @@ var ts; /*@internal*/ ProjectService.prototype.includePackageJsonAutoImports = function () { switch (this.hostConfiguration.preferences.includePackageJsonAutoImports) { - case "on": return 1 /* On */; - case "off": return 0 /* Off */; - default: return 2 /* Auto */; + case "on": return 1 /* PackageJsonAutoImportPreference.On */; + case "off": return 0 /* PackageJsonAutoImportPreference.Off */; + default: return 2 /* PackageJsonAutoImportPreference.Auto */; } }; /*@internal*/ @@ -173548,7 +174252,7 @@ var ts; return cache.get(toFileName); }, set: function (fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) { - ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isAutoImportable*/ true)); + ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false)); // If any module specifiers were generated based off paths in node_modules, // a package.json file in that package was read and is an input to the cached. // Instead of watching each individual package.json file, set up a wildcard @@ -173574,17 +174278,17 @@ var ts; info.modulePaths = modulePaths; } else { - cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isAutoImportable*/ undefined)); + cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined)); } }, - setIsAutoImportable: function (fromFileName, toFileName, preferences, options, isAutoImportable) { + setBlockedByPackageJsonDependencies: function (fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) { var cache = ensureCache(fromFileName, preferences, options); var info = cache.get(toFileName); if (info) { - info.isAutoImportable = isAutoImportable; + info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies; } else { - cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isAutoImportable)); + cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies)); } }, clear: function () { @@ -173610,10 +174314,10 @@ var ts; return cache || (cache = new ts.Map()); } function key(fromFileName, preferences, options) { - return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode; + return "".concat(fromFileName, ",").concat(preferences.importModuleSpecifierEnding, ",").concat(preferences.importModuleSpecifierPreference, ",").concat(options.overrideImportMode); } - function createInfo(modulePaths, moduleSpecifiers, isAutoImportable) { - return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isAutoImportable: isAutoImportable }; + function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) { + return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies }; } } server.createModuleSpecifierCache = createModuleSpecifierCache; @@ -173641,7 +174345,7 @@ var ts; directoryHasPackageJson: directoryHasPackageJson, searchDirectoryAndAncestors: function (directory) { ts.forEachAncestorDirectory(directory, function (ancestor) { - if (directoryHasPackageJson(ancestor) !== 3 /* Maybe */) { + if (directoryHasPackageJson(ancestor) !== 3 /* Ternary.Maybe */) { return true; } var packageJsonFileName = host.toPath(ts.combinePaths(ancestor, "package.json")); @@ -173660,9 +174364,9 @@ var ts; directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); } function directoryHasPackageJson(directory) { - return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : - directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : - 3 /* Maybe */; + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* Ternary.True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* Ternary.False */ : + 3 /* Ternary.Maybe */; } } server.createPackageJsonCache = createPackageJsonCache; @@ -173769,10 +174473,10 @@ var ts; var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); if (verboseLogging) { - logger.info(msg.type + ":" + server.indent(json)); + logger.info("".concat(msg.type, ":").concat(server.indent(json))); } var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + return "Content-Length: ".concat(1 + len, "\r\n\r\n").concat(json).concat(newLine); } server.formatMessage = formatMessage; /** @@ -173819,10 +174523,10 @@ var ts; try { if (this.operationHost.isCancellationRequested()) { stop = true; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId, early: true }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "stepAction", { seq: this.requestId }); action(this); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -173833,11 +174537,11 @@ var ts; stop = true; // ignore cancellation request if (e instanceof ts.OperationCanceledException) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message }); - this.operationHost.logError(e, "delayed processing of request " + this.requestId); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepError", { seq: this.requestId, message: e.message }); + this.operationHost.logError(e, "delayed processing of request ".concat(this.requestId)); } } if (stop || !this.hasPendingWork()) { @@ -173895,7 +174599,8 @@ var ts; var providePrefixAndSuffixTextForRename = _a.providePrefixAndSuffixTextForRename; var outputs = []; var seen = createDocumentSpanSet(); - combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, tryAddToTodo) { + combineProjectOutputWorker(projects, defaultProject, initialLocation, + /*isForRename*/ true, function (project, location, tryAddToTodo) { var projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename); if (projectOutputs) { for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) { @@ -173909,18 +174614,20 @@ var ts; }); return outputs; } - function getDefinitionLocation(defaultProject, initialLocation) { - var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos); + function getDefinitionLocation(defaultProject, initialLocation, isForRename) { + var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, isForRename); var info = infos && ts.firstOrUndefined(infos); return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined; } function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) { - logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName()); + combineProjectOutputWorker(projects, defaultProject, initialLocation, + /*isForRename*/ false, function (project, location, getMappedLocation) { + var _a, _b; + logger.info("Finding references to ".concat(location.fileName, " position ").concat(location.pos, " in project ").concat(project.getProjectName())); var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos); if (projectOutputs) { - var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined; + var clearIsDefinition = ((_b = (_a = projectOutputs[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined; var _loop_9 = function (referencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? @@ -173930,8 +174637,8 @@ var ts; symbolToAddTo = { definition: definition, references: [] }; outputs.push(symbolToAddTo); } - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var ref = _b[_a]; + for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) { + var ref = _d[_c]; // If it's in a mapped file, that is added to the todo list by `getMappedLocation`. if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) { if (clearIsDefinition) { @@ -173963,7 +174670,7 @@ var ts; }); } } - function combineProjectOutputWorker(projects, defaultProject, initialLocation, cb) { + function combineProjectOutputWorker(projects, defaultProject, initialLocation, isForRename, cb) { var projectService = defaultProject.projectService; var toDo; var seenProjects = new ts.Set(); @@ -173974,7 +174681,7 @@ var ts; }); // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. if (initialLocation) { - var defaultDefinition_1 = getDefinitionLocation(defaultProject, initialLocation); + var defaultDefinition_1 = getDefinitionLocation(defaultProject, initialLocation, isForRename); if (defaultDefinition_1) { var getGeneratedDefinition_1 = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition_1.fileName) ? defaultDefinition_1 : @@ -174246,6 +174953,9 @@ var ts; _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) { return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); }, + _a[server.CommandNames.FindSourceDefinition] = function (request) { + return _this.requiredResponse(_this.findSourceDefinition(request.arguments)); + }, _a[server.CommandNames.EmitOutput] = function (request) { return _this.requiredResponse(_this.getEmitOutput(request.arguments)); }, @@ -174596,14 +175306,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidPartialSemanticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.PartialSemantic")); }); }); break; case ts.LanguageServiceMode.Syntactic: invalidSyntacticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.Syntactic")); }); }); break; @@ -174678,7 +175388,7 @@ var ts; }; Session.prototype.projectsUpdatedInBackgroundEvent = function (openFiles) { var _this = this; - this.projectService.logger.info("got projects updated in background, updating diagnostics for " + openFiles); + this.projectService.logger.info("got projects updated in background, updating diagnostics for ".concat(openFiles)); if (openFiles.length) { if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { // For now only queue error checking for open files. We can change this to include non open files as well @@ -174708,17 +175418,17 @@ var ts; var scriptInfo = project.getScriptInfoForNormalizedPath(file); if (scriptInfo) { var text = ts.getSnapshotText(scriptInfo.getSnapshot()); - msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; + msg += "\n\nFile text of ".concat(fileRequest.file, ":").concat(server.indent(text), "\n"); } } catch (_b) { } // eslint-disable-line no-empty } if (err.ProgramFiles) { - msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; + msg += "\n\nProgram files: ".concat(JSON.stringify(err.ProgramFiles), "\n"); msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { - msg += "\nProject '" + project.projectName + "' (" + server.ProjectKind[project.projectKind] + ") " + counter_1 + "\n"; + msg += "\nProject '".concat(project.projectName, "' (").concat(server.ProjectKind[project.projectKind], ") ").concat(counter_1, "\n"); msg += project.filesToString(/*writeProjectFileNames*/ true); msg += "\n-----------------------------------------------\n"; counter_1++; @@ -174733,7 +175443,7 @@ var ts; Session.prototype.send = function (msg) { if (msg.type === "event" && !this.canUseEvents) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + this.logger.info("Session does not support events: ignored event: ".concat(JSON.stringify(msg))); } return; } @@ -174741,7 +175451,7 @@ var ts; }; Session.prototype.writeMessage = function (msg) { var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); - ts.perfLogger.logEvent("Response message size: " + msgText.length); + ts.perfLogger.logEvent("Response message size: ".concat(msgText.length)); this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { @@ -174793,7 +175503,7 @@ var ts; this.send(res); }; Session.prototype.semanticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file) ? server.emptyArray : project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; }); @@ -174801,12 +175511,12 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.syntacticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.suggestionCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; @@ -174884,7 +175594,7 @@ var ts; if (!projects) { return; } - this.logger.info("cleaning " + caption); + this.logger.info("cleaning ".concat(caption)); for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { var p = projects_4[_i]; p.getLanguageService(/*ensureSynchronized*/ false).cleanupSemanticCache(); @@ -174905,7 +175615,7 @@ var ts; }; Session.prototype.getEncodedSemanticClassifications = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var format = args.format === "2020" ? "2020" /* TwentyTwenty */ : "original" /* Original */; + var format = args.format === "2020" ? "2020" /* SemanticClassificationFormat.TwentyTwenty */ : "original" /* SemanticClassificationFormat.Original */; return project.getLanguageService().getEncodedSemanticClassifications(file, args, format); }; Session.prototype.getProject = function (projectFileName) { @@ -174987,7 +175697,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified }); + return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -175014,6 +175724,152 @@ var ts; textSpan: textSpan, }; }; + Session.prototype.findSourceDefinition = function (args) { + var _a; + var _b = this.getFileAndProject(args), file = _b.file, project = _b.project; + var position = this.getPositionInFile(args, file); + var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position); + var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice(); + var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) || + ts.some(definitions, function (d) { return !!d.failedAliasResolution; })); + if (needsJsResolution) { + var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual); + definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); }); + var noDtsProject = project.getNoDtsResolutionProject([file]); + var ls = noDtsProject.getLanguageService(); + var jsDefinitions = (_a = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file; }); + if (ts.some(jsDefinitions)) { + for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) { + var jsDefinition = jsDefinitions_1[_i]; + if (jsDefinition.unverified) { + var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram()); + if (ts.some(refined)) { + for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) { + var def = refined_1[_c]; + definitionSet_1.add(def); + } + continue; + } + } + definitionSet_1.add(jsDefinition); + } + } + else { + var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }); + for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) { + var candidate = _e[_d]; + var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject); + if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) { + continue; + } + var noDtsProgram = ls.getProgram(); + var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch)); + for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) { + var match = _g[_f]; + definitionSet_1.add(match); + } + } + } + definitions = ts.arrayFrom(definitionSet_1.values()); + } + definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; }); + return this.mapDefinitionInfo(definitions, project); + function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) { + var _a; + var nodeModulesPathParts = ts.getNodeModulePathParts(fileName); + if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) { + // Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up. + var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex); + var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); + var compilerOptions = project.getCompilationSettings(); + var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions); + if (!packageJson) + return undefined; + // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext - + // Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be + // resolved from the package root under --moduleResolution node + var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache()); + // This substring is correct only because we checked for a single `/node_modules/` at the top. + var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex); + var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart)); + var path_1 = project.toPath(fileName); + if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) { + // This file was the main entrypoint of a package. Try to resolve that same package name with + // the auxiliary project that only resolves to implementation files. + var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0]; + return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName; + } + else { + // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package. + var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1); + var specifier = "".concat(packageName, "/").concat(ts.removeFileExtension(pathToFileInPackage)); + var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0]; + return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName; + } + } + // We're not in node_modules, and we only get to this function if non-dts module resolution failed. + // I'm not sure what else I can do here that isn't already covered by that module resolution. + return undefined; + } + // In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition + // for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later. + function getAmbientCandidatesByClimbingAccessChain() { + var ls = project.getLanguageService(); + var program = ls.getProgram(); + var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position); + if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) { + return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) { + var _a; + if (nameInChain === initialNode) + return undefined; + var candidates = (_a = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }).map(function (d) { return ({ + fileName: d.fileName, + name: ts.getTextOfIdentifierOrLiteral(initialNode) + }); }); + if (ts.some(candidates)) { + return candidates; + } + }) || server.emptyArray; + } + return server.emptyArray; + } + function tryRefineDefinition(definition, program, noDtsProgram) { + var _a; + var fileToSearch = noDtsProgram.getSourceFile(definition.fileName); + if (!fileToSearch) { + return undefined; + } + var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position); + var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode); + var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* SyntaxKind.ImportSpecifier */); + if (!importSpecifier) + return undefined; + var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text; + return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram); + } + function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) { + var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch); + return ts.mapDefined(matches, function (match) { + var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match); + var decl = ts.getDeclarationFromName(match); + if (symbol && decl) { + // I think the last argument to this is supposed to be the start node, but it doesn't seem important. + // Callers internal to GoToDefinition already get confused about this. + return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true); + } + }); + } + function ensureRoot(project, fileName) { + var info = project.getScriptInfo(fileName); + if (!info) + return false; + if (!project.containsScriptInfo(info)) { + project.addRoot(info); + project.updateGraph(); + } + return true; + } + }; Session.prototype.getEmitOutput = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; if (!project.shouldEmitFile(project.getScriptInfo(file))) { @@ -175314,7 +176170,7 @@ var ts; var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); }); return { refs: refs, - symbolName: "\"" + args.file + "\"" + symbolName: "\"".concat(args.file, "\"") }; }; /** @@ -175515,7 +176371,7 @@ var ts; var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }), project.projectService.getFormatCodeOptions(file)); if (completions === undefined) return undefined; - if (kind === "completions-full" /* CompletionsFull */) + if (kind === "completions-full" /* protocol.CommandTypes.CompletionsFull */) return completions; var prefix = args.prefix || ""; var entries = ts.mapDefined(completions.entries, function (entry) { @@ -175542,7 +176398,7 @@ var ts; }; } }); - if (kind === "completions" /* Completions */) { + if (kind === "completions" /* protocol.CommandTypes.Completions */) { if (completions.metadata) entries.metadata = completions.metadata; return entries; @@ -175577,7 +176433,7 @@ var ts; return undefined; } var compilationSettings = project.getCompilationSettings(); - if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) { + if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) { // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled return undefined; } @@ -175941,7 +176797,7 @@ var ts; }); var badCode = args.errorCodes.find(function (c) { return !existingDiagCodes_1.includes(c); }); if (badCode !== undefined) { - e.message = "BADCLIENT: Bad error code, " + badCode + " not found in range " + startPosition + ".." + endPosition + " (found: " + existingDiagCodes_1.join(", ") + "); could have caused this error:\n" + e.message; + e.message = "BADCLIENT: Bad error code, ".concat(badCode, " not found in range ").concat(startPosition, "..").concat(endPosition, " (found: ").concat(existingDiagCodes_1.join(", "), "); could have caused this error:\n").concat(e.message); } throw e; } @@ -176057,7 +176913,7 @@ var ts; else { var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217 if (!info.isScriptOpen()) { - if (ts.fileExtensionIs(fileNameInProject, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileNameInProject)) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -176218,7 +177074,7 @@ var ts; }; Session.prototype.addProtocolHandler = function (command, handler) { if (this.handlers.has(command)) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); + throw new Error("Protocol handler already exists for command \"".concat(command, "\"")); } this.handlers.set(command, handler); }; @@ -176247,8 +177103,8 @@ var ts; return this.executeWithRequestId(request.seq, function () { return handler(request); }); } else { - this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err); - this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: " + request.command); + this.logger.msg("Unrecognized JSON command:".concat(server.stringifyIndented(request)), server.Msg.Err); + this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: ".concat(request.command)); return { responseRequired: false }; } }; @@ -176259,7 +177115,7 @@ var ts; if (this.logger.hasLevel(server.LogLevel.requestTime)) { start = this.hrtime(); if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request:" + server.indent(this.toStringMessage(message))); + this.logger.info("request:".concat(server.indent(this.toStringMessage(message)))); } } var request; @@ -176267,23 +177123,23 @@ var ts; try { request = this.parseMessage(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "request", { seq: request.seq, command: request.command }); ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": elapsed time (in milliseconds) ").concat(elapsedTime)); } else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": async elapsed time (in milliseconds) ").concat(elapsedTime)); } } // Note: Log before writing the response, else the editor can complete its activity before the server does ts.perfLogger.logStopCommand("" + request.command, "Success"); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "response", { seq: request.seq, command: request.command, success: !!response }); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -176297,13 +177153,13 @@ var ts; if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, this.toStringMessage(message), relevantFile); ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -176414,7 +177270,7 @@ var ts; this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = 2 /* Entire */; + this.state = 2 /* CharRangeSection.Entire */; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -176505,7 +177361,7 @@ var ts; // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { - this.state = 4 /* End */; + this.state = 4 /* CharRangeSection.End */; } // always pop stack because post only called when child has been visited this.stack.pop(); @@ -176513,9 +177369,9 @@ var ts; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { // currentNode corresponds to parent, but in the new tree var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === 2 /* Entire */) && (nodeType === 1 /* Start */)) { + if ((this.state === 2 /* CharRangeSection.Entire */) && (nodeType === 1 /* CharRangeSection.Start */)) { // if range is on single line, we will never make this state transition - this.state = 1 /* Start */; + this.state = 1 /* CharRangeSection.Start */; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -176528,14 +177384,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case 0 /* PreStart */: + case 0 /* CharRangeSection.PreStart */: this.goSubtree = false; - if (this.state !== 4 /* End */) { + if (this.state !== 4 /* CharRangeSection.End */) { currentNode.add(lineCollection); } break; - case 1 /* Start */: - if (this.state === 4 /* End */) { + case 1 /* CharRangeSection.Start */: + if (this.state === 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -176544,8 +177400,8 @@ var ts; this.startPath.push(child); } break; - case 2 /* Entire */: - if (this.state !== 4 /* End */) { + case 2 /* CharRangeSection.Entire */: + if (this.state !== 4 /* CharRangeSection.End */) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -176558,11 +177414,11 @@ var ts; } } break; - case 3 /* Mid */: + case 3 /* CharRangeSection.Mid */: this.goSubtree = false; break; - case 4 /* End */: - if (this.state !== 4 /* End */) { + case 4 /* CharRangeSection.End */: + if (this.state !== 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -176573,9 +177429,9 @@ var ts; } } break; - case 5 /* PostEnd */: + case 5 /* CharRangeSection.PostEnd */: this.goSubtree = false; - if (this.state !== 1 /* Start */) { + if (this.state !== 1 /* CharRangeSection.Start */) { currentNode.add(lineCollection); } break; @@ -176586,10 +177442,10 @@ var ts; }; // just gather text from the leaves EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === 1 /* Start */) { + if (this.state === 1 /* CharRangeSection.Start */) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === 2 /* Entire */) { + else if (this.state === 2 /* CharRangeSection.Entire */) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -176947,20 +177803,20 @@ var ts; // find sub-tree containing start var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* PreStart */); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* CharRangeSection.PreStart */); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } // Case I: both start and end of range in same subtree if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* Entire */)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* CharRangeSection.Entire */)) { return; } } else { // Case II: start and end of range in different subtrees (possibly with subtrees in the middle) - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* Start */)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* CharRangeSection.Start */)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -176968,7 +177824,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* Mid */)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* CharRangeSection.Mid */)) { return; } adjustedLength -= childCharCount; @@ -176976,7 +177832,7 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* End */)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* CharRangeSection.End */)) { return; } } @@ -176986,7 +177842,7 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, 5 /* PostEnd */); + this.skipChild(0, 0, ej, walkFns, 5 /* CharRangeSection.PostEnd */); } } } @@ -177214,7 +178070,7 @@ var ts; } if (!this.canWrite()) return; - s = "[" + server.nowString() + "] " + s + "\n"; + s = "[".concat(server.nowString(), "] ").concat(s, "\n"); if (!this.inGroup || this.firstInGroup) { var prefix = BaseLogger.padStringRight(type + " " + this.seq.toString(), " "); s = prefix + s; @@ -177331,12 +178187,12 @@ var ts; WorkerSession.prototype.send = function (msg) { if (msg.type === "event" && !this.canUseEvents) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + this.logger.info("Session does not support events: ignored event: ".concat(JSON.stringify(msg))); } return; } if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info(msg.type + ":" + server.indent(JSON.stringify(msg))); + this.logger.info("".concat(msg.type, ":").concat(server.indent(JSON.stringify(msg)))); } this.webHost.writeMessage(msg); }; @@ -177988,11 +178844,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -178039,7 +178895,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -178076,7 +178932,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -178217,9 +179073,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -178246,7 +179102,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", @@ -178309,13 +179165,13 @@ var ts; function getEntireValue(initialIndex) { var pathStart = args[initialIndex]; var extraPartCounter = 0; - if (pathStart.charCodeAt(0) === 34 /* doubleQuote */ && - pathStart.charCodeAt(pathStart.length - 1) !== 34 /* doubleQuote */) { + if (pathStart.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ && + pathStart.charCodeAt(pathStart.length - 1) !== 34 /* CharacterCodes.doubleQuote */) { for (var i = initialIndex + 1; i < args.length; i++) { pathStart += " "; pathStart += args[i]; extraPartCounter++; - if (pathStart.charCodeAt(pathStart.length - 1) === 34 /* doubleQuote */) + if (pathStart.charCodeAt(pathStart.length - 1) === 34 /* CharacterCodes.doubleQuote */) break; } } @@ -178399,23 +179255,23 @@ var ts; var status = cacheKey && statusCache_1.get(cacheKey); if (status === undefined) { if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info(cacheKey + " for path " + path + " not found in cache..."); + logger.info("".concat(cacheKey, " for path ").concat(path, " not found in cache...")); } try { var args = [ts.combinePaths(__dirname, "watchGuard.js"), path]; if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("Starting " + process.execPath + " with args:" + server.stringifyIndented(args)); + logger.info("Starting ".concat(process.execPath, " with args:").concat(server.stringifyIndented(args))); } childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { ELECTRON_RUN_AS_NODE: "1" } }); status = true; if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("WatchGuard for path " + path + " returned: OK"); + logger.info("WatchGuard for path ".concat(path, " returned: OK")); } } catch (e) { status = false; if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("WatchGuard for path " + path + " returned: " + e.message); + logger.info("WatchGuard for path ".concat(path, " returned: ").concat(e.message)); } } if (cacheKey) { @@ -178423,7 +179279,7 @@ var ts; } } else if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("watchDirectory for " + path + " uses cached drive information."); + logger.info("watchDirectory for ".concat(path, " uses cached drive information.")); } if (status) { // this drive is safe to use - call real 'watchDirectory' @@ -178545,11 +179401,11 @@ var ts; // relative path - assume file is on the current drive return currentDriveKey; } - if (path.charCodeAt(1) === 58 /* colon */ && path.charCodeAt(2) === 47 /* slash */) { + if (path.charCodeAt(1) === 58 /* CharacterCodes.colon */ && path.charCodeAt(2) === 47 /* CharacterCodes.slash */) { // rooted path that starts with c:/... - extract drive letter return ts.toFileNameLowerCase(path.charAt(0)); } - if (path.charCodeAt(0) === 47 /* slash */ && path.charCodeAt(1) !== 47 /* slash */) { + if (path.charCodeAt(0) === 47 /* CharacterCodes.slash */ && path.charCodeAt(1) !== 47 /* CharacterCodes.slash */) { // rooted path that starts with slash - /somename - use key for current drive return currentDriveKey; } @@ -178557,7 +179413,7 @@ var ts; return undefined; } function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; + return s.length > 2 && s.charCodeAt(0) === 47 /* CharacterCodes.slash */ && s.charCodeAt(1) === 47 /* CharacterCodes.slash */; } // This is the function that catches the exceptions when watching directory, and yet lets project service continue to function // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point @@ -178566,7 +179422,7 @@ var ts; return originalWatchDirectory(path, callback, recursive, options); } catch (e) { - logger.info("Exception when creating directory watcher: " + e.message); + logger.info("Exception when creating directory watcher: ".concat(e.message)); return ts.noopFileWatcher; } } @@ -178606,7 +179462,7 @@ var ts; NodeTypingsInstaller.prototype.isKnownTypesPackageName = function (name) { // We want to avoid looking this up in the registry as that is expensive. So first check that it's actually an NPM package. var validationResult = ts.JsTyping.validatePackageName(name); - if (validationResult !== 0 /* Ok */) { + if (validationResult !== 0 /* JsTyping.NameValidationResult.Ok */) { return false; } if (this.requestedRegistry) { @@ -178635,7 +179491,7 @@ var ts; args.push(server.Arguments.EnableTelemetry); } if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { - args.push(server.Arguments.LogFile, ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); + args.push(server.Arguments.LogFile, ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-".concat(process.pid, ".log"))); } if (this.typingSafeListLocation) { args.push(server.Arguments.TypingSafeListLocation, this.typingSafeListLocation); @@ -178659,7 +179515,7 @@ var ts; var currentPort = match[2] !== undefined ? +match[2] : match[1].charAt(0) === "d" ? 5858 : 9229; - execArgv.push("--" + match[1] + "=" + (currentPort + 1)); + execArgv.push("--".concat(match[1], "=").concat(currentPort + 1)); break; } } @@ -178685,13 +179541,13 @@ var ts; var request = server.createInstallTypingsRequest(project, typeAcquisition, unresolvedImports); if (this.logger.hasLevel(server.LogLevel.verbose)) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Scheduling throttled operation:" + server.stringifyIndented(request)); + this.logger.info("Scheduling throttled operation:".concat(server.stringifyIndented(request))); } } var operationId = project.getProjectName(); var operation = function () { if (_this.logger.hasLevel(server.LogLevel.verbose)) { - _this.logger.info("Sending request:" + server.stringifyIndented(request)); + _this.logger.info("Sending request:".concat(server.stringifyIndented(request))); } _this.send(request); }; @@ -178701,7 +179557,7 @@ var ts; } else { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Deferring request for: " + operationId); + this.logger.info("Deferring request for: ".concat(operationId)); } this.requestQueue.push(queuedRequest); this.requestMap.set(operationId, queuedRequest); @@ -178709,7 +179565,7 @@ var ts; }; NodeTypingsInstaller.prototype.handleMessage = function (response) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Received response:" + server.stringifyIndented(response)); + this.logger.info("Received response:".concat(server.stringifyIndented(response))); } switch (response.kind) { case server.EventTypesRegistry: @@ -178787,7 +179643,7 @@ var ts; break; } if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Skipping defunct request for: " + queuedRequest.operationId); + this.logger.info("Skipping defunct request for: ".concat(queuedRequest.operationId)); } } this.projectService.updateTypingsForProject(response); @@ -178800,7 +179656,7 @@ var ts; }; NodeTypingsInstaller.prototype.scheduleRequest = function (request) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Scheduling request for: " + request.operationId); + this.logger.info("Scheduling request for: ".concat(request.operationId)); } this.activeRequestCount++; this.host.setTimeout(request.operation, NodeTypingsInstaller.requestDelayMillis); @@ -178848,7 +179704,7 @@ var ts; if (this.canUseEvents && this.eventPort) { if (!this.eventSocket) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("eventPort: event \"" + eventName + "\" queued, but socket not yet initialized"); + this.logger.info("eventPort: event \"".concat(eventName, "\" queued, but socket not yet initialized")); } (this.socketEventQueue || (this.socketEventQueue = [])).push({ body: body, eventName: eventName }); return; @@ -178892,7 +179748,7 @@ var ts; var verboseLogging = logger.hasLevel(server.LogLevel.verbose); if (verboseLogging) { var json = JSON.stringify(msg); - logger.info(msg.type + ":" + server.indent(json)); + logger.info("".concat(msg.type, ":").concat(server.indent(json))); } process.send(msg); }; @@ -178954,7 +179810,7 @@ var ts; return ts.combinePaths(ts.combinePaths(cacheLocation, "typescript"), ts.versionMajorMinor); } default: - return ts.Debug.fail("unsupported platform '" + process.platform + "'"); + return ts.Debug.fail("unsupported platform '".concat(process.platform, "'")); } } function getNonWindowsCacheLocation(platformIsDarwin) { @@ -178964,7 +179820,7 @@ var ts; var usersDir = platformIsDarwin ? "Users" : "home"; var homePath = (os.homedir && os.homedir()) || process.env.HOME || - ((process.env.LOGNAME || process.env.USER) && "/" + usersDir + "/" + (process.env.LOGNAME || process.env.USER)) || + ((process.env.LOGNAME || process.env.USER) && "/".concat(usersDir, "/").concat(process.env.LOGNAME || process.env.USER)) || os.tmpdir(); var cacheFolder = platformIsDarwin ? "Library/Caches" @@ -179123,10 +179979,10 @@ var ts; var args = _a.args, logger = _a.logger, cancellationToken = _a.cancellationToken, serverMode = _a.serverMode, unknownServerMode = _a.unknownServerMode, startServer = _a.startSession; var syntaxOnly = server.hasArgument("--syntaxOnly"); logger.info("Starting TS Server"); - logger.info("Version: " + ts.version); - logger.info("Arguments: " + args.join(" ")); - logger.info("Platform: " + platform + " NodeVersion: " + ts.getNodeMajorVersion() + " CaseSensitive: " + ts.sys.useCaseSensitiveFileNames); - logger.info("ServerMode: " + serverMode + " syntaxOnly: " + syntaxOnly + " hasUnknownServerMode: " + unknownServerMode); + logger.info("Version: ".concat(ts.version)); + logger.info("Arguments: ".concat(args.join(" "))); + logger.info("Platform: ".concat(platform, " NodeVersion: ").concat(ts.getNodeMajorVersion(), " CaseSensitive: ").concat(ts.sys.useCaseSensitiveFileNames)); + logger.info("ServerMode: ".concat(serverMode, " syntaxOnly: ").concat(syntaxOnly, " hasUnknownServerMode: ").concat(unknownServerMode)); ts.setStackTraceLimit(); if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 9ea997539f55f..f7e45674ac056 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2172,7 +2172,9 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export interface WriteFileCallbackData { + } + export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -2394,7 +2396,6 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, - NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2892,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2901,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3073,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4817,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6434,7 +6435,18 @@ declare namespace ts { argumentIndex: number; argumentCount: number; } + enum CompletionInfoFlags { + None = 0, + MayIncludeAutoImports = 1, + IsImportStatementCompletion = 2, + IsContinuation = 4, + ResolvedModuleSpecifiers = 8, + ResolvedModuleSpecifiersBeyondLimit = 16, + MayIncludeMethodSnippets = 32 + } interface CompletionInfo { + /** For performance telemetry. */ + flags?: CompletionInfoFlags; /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; @@ -6810,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6829,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. @@ -7039,6 +7051,7 @@ declare namespace ts.server.protocol { Rename = "rename", Saveto = "saveto", SignatureHelp = "signatureHelp", + FindSourceDefinition = "findSourceDefinition", Status = "status", TypeDefinition = "typeDefinition", ProjectInfo = "projectInfo", @@ -7658,6 +7671,9 @@ declare namespace ts.server.protocol { interface DefinitionAndBoundSpanRequest extends FileLocationRequest { readonly command: CommandTypes.DefinitionAndBoundSpan; } + interface FindSourceDefinitionRequest extends FileLocationRequest { + readonly command: CommandTypes.FindSourceDefinition; + } interface DefinitionAndBoundSpanResponse extends Response { readonly body: DefinitionInfoAndBoundSpan; } @@ -8818,6 +8834,7 @@ declare namespace ts.server.protocol { body?: CompletionInfo; } interface CompletionInfo { + readonly flags?: number; readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; @@ -9906,7 +9923,8 @@ declare namespace ts.server { Inferred = 0, Configured = 1, External = 2, - AutoImportProvider = 3 + AutoImportProvider = 3, + Auxiliary = 4 } function allRootFilesAreJsOrDts(project: Project): boolean; function allFilesAreJsOrDts(project: Project): boolean; @@ -10641,6 +10659,7 @@ declare namespace ts.server { private getDefinition; private mapDefinitionInfoLocations; private getDefinitionAndBoundSpan; + private findSourceDefinition; private getEmitOutput; private mapJSDocTagInfo; private mapDisplayParts; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 0d09a6e528f72..340bea33b97f7 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -21,7 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -294,7 +294,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "".concat(ts.versionMajorMinor, ".1-rc"); /* @internal */ var Comparison; (function (Comparison) { @@ -341,7 +341,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -1033,9 +1033,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -1071,7 +1071,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -1125,27 +1125,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1385,12 +1385,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1844,7 +1844,7 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ @@ -1935,7 +1935,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -2007,11 +2007,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -2029,7 +2029,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -2046,14 +2046,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -2084,13 +2084,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -2120,7 +2120,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2181,9 +2181,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2302,24 +2302,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2329,7 +2329,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2385,7 +2385,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2485,12 +2485,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2621,7 +2621,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2700,7 +2700,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2708,12 +2708,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2723,26 +2723,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2773,42 +2773,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2829,7 +2829,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2850,7 +2850,7 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "" + result + (result ? "|" : "") + enumName; + result = "".concat(result).concat(result ? "|" : "").concat(enumName); remainingFlags &= ~enumValue; } } @@ -2947,20 +2947,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2999,7 +2999,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -3051,10 +3051,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -3063,35 +3063,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -3123,11 +3123,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -3159,7 +3159,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3206,10 +3206,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3323,9 +3323,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3340,11 +3340,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3373,11 +3373,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3394,7 +3394,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3611,7 +3611,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3909,7 +3909,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3921,11 +3921,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -4015,20 +4015,20 @@ var ts; } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -4064,7 +4064,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -4073,7 +4073,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -4081,7 +4081,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -4090,7 +4090,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -4100,7 +4100,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -4108,7 +4108,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -4117,7 +4117,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -4135,7 +4135,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4854,7 +4854,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; - NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -5471,10 +5470,11 @@ var ts; ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16"; ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var ModuleDetectionKind; @@ -5484,7 +5484,7 @@ var ts; */ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy"; /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto"; /** @@ -5529,8 +5529,8 @@ var ts; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + ModuleKind[ModuleKind["Node16"] = 100] = "Node16"; ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); var JsxEmit; @@ -6066,37 +6066,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6168,7 +6168,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6385,7 +6385,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6637,7 +6637,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6650,7 +6650,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6666,7 +6666,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6689,7 +6689,7 @@ var ts; var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6784,7 +6784,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6839,7 +6839,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6871,7 +6871,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -7126,7 +7126,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7135,7 +7135,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7151,7 +7151,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7253,7 +7253,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -7278,7 +7278,7 @@ var ts; } } if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -7294,7 +7294,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7445,8 +7445,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7458,10 +7458,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7525,8 +7525,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7549,7 +7549,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7636,16 +7636,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7659,18 +7659,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7690,7 +7690,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7767,7 +7767,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -8051,17 +8051,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -8078,7 +8078,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8452,6 +8452,7 @@ var ts; _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), @@ -8463,10 +8464,10 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), - Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -8481,7 +8482,7 @@ var ts; 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_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_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -8512,7 +8513,7 @@ var ts; await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -8564,7 +8565,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), - Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), @@ -8582,7 +8583,7 @@ var ts; Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), - Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."), + Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."), resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), @@ -8593,7 +8594,7 @@ var ts; An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), - auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8602,7 +8603,8 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), - This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -8853,7 +8855,6 @@ var ts; A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), - 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."), Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), 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."), @@ -8911,6 +8912,7 @@ var ts; _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -9066,6 +9068,7 @@ var ts; This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), @@ -9079,8 +9082,8 @@ var ts; Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), @@ -9191,6 +9194,7 @@ var ts; This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -9746,7 +9750,6 @@ var ts; This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), - JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -10056,100 +10059,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10238,16 +10241,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10276,17 +10279,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10311,7 +10314,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10389,18 +10392,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10414,50 +10417,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10471,29 +10474,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10504,10 +10507,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10517,24 +10520,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10542,7 +10545,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10566,8 +10569,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10578,18 +10581,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10650,12 +10653,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10665,20 +10668,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10689,7 +10692,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10714,7 +10717,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10769,17 +10772,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10798,7 +10801,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10821,15 +10824,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10884,8 +10887,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10909,7 +10912,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10919,15 +10922,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10940,7 +10943,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10952,10 +10955,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -11013,8 +11016,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11029,11 +11032,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -11043,7 +11046,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -11057,7 +11060,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11067,7 +11070,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -11075,7 +11078,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11088,7 +11091,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -11096,28 +11099,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11125,10 +11128,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11151,47 +11154,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11199,29 +11202,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11229,14 +11232,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11269,7 +11272,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11285,7 +11288,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11295,7 +11298,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11313,11 +11316,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11326,7 +11329,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11345,14 +11348,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11363,8 +11366,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11379,101 +11382,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11482,98 +11485,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11586,20 +11589,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11607,7 +11610,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11619,18 +11622,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11638,10 +11641,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11649,10 +11652,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11660,175 +11663,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11838,7 +11841,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11849,23 +11852,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11879,41 +11882,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11921,13 +11924,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11936,19 +11939,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11958,7 +11961,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11979,9 +11982,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11989,7 +11992,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -12003,42 +12006,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -12046,20 +12049,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -12082,7 +12085,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -12095,16 +12098,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12125,10 +12128,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12140,86 +12143,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12294,9 +12297,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12362,23 +12365,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12586,9 +12589,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12596,7 +12599,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12626,14 +12629,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12747,7 +12750,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12765,7 +12768,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12776,7 +12779,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12806,30 +12809,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12864,42 +12867,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -13192,16 +13195,16 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a @@ -13212,7 +13215,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13239,33 +13242,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13300,7 +13303,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13309,25 +13312,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13336,12 +13339,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13357,7 +13360,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13366,7 +13369,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13387,7 +13390,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13397,7 +13400,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13406,8 +13409,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13416,13 +13419,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13434,13 +13437,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13458,20 +13461,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13479,12 +13482,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13493,24 +13496,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13530,18 +13533,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13550,14 +13553,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13572,30 +13575,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13605,13 +13608,13 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13620,12 +13623,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13640,8 +13643,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13652,8 +13655,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13661,15 +13664,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13678,9 +13681,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13701,8 +13704,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13711,10 +13714,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13726,8 +13729,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13736,26 +13739,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13763,13 +13766,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13779,36 +13782,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13821,13 +13824,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13836,11 +13839,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13857,15 +13860,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13873,8 +13876,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13885,13 +13888,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13909,18 +13912,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13944,115 +13947,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14079,10 +14082,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14096,76 +14099,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14175,15 +14178,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14209,13 +14212,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14223,12 +14226,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14257,11 +14260,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion @@ -14302,7 +14305,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14463,11 +14466,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14498,28 +14501,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14530,16 +14533,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14554,7 +14557,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14607,7 +14610,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14641,7 +14644,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14673,9 +14676,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14687,13 +14690,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14702,7 +14705,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14710,10 +14713,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14724,7 +14727,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14735,7 +14738,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14896,62 +14899,62 @@ var ts; var _a; // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14966,21 +14969,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -15004,16 +15007,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -15025,9 +15028,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -15039,7 +15042,7 @@ var ts; } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isCommonJSContainingModuleKind(kind) { - return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext; } function isEffectiveExternalModule(node, compilerOptions) { return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); @@ -15051,10 +15054,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15084,24 +15087,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15111,9 +15114,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15123,25 +15126,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15151,25 +15154,29 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; } } ts.isAnyImportSyntax = isAnyImportSyntax; + function isAnyImportOrBareOrAccessedRequire(node) { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15210,19 +15217,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15237,21 +15244,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15341,7 +15348,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15355,7 +15362,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15364,29 +15371,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15418,36 +15425,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15456,12 +15463,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15480,24 +15487,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15506,48 +15513,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15556,40 +15563,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15614,23 +15621,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15640,23 +15647,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15679,10 +15686,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15692,12 +15699,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15705,14 +15712,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15724,21 +15731,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15749,13 +15756,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15766,7 +15773,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15774,30 +15781,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15859,14 +15866,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15881,9 +15888,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15894,27 +15901,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15927,17 +15934,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15961,9 +15968,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15985,28 +15992,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16022,21 +16029,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -16045,8 +16052,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -16054,34 +16061,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16089,10 +16096,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16105,25 +16112,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16139,11 +16146,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16159,9 +16166,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16169,64 +16176,64 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16236,49 +16243,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16286,10 +16293,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16297,7 +16304,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16310,7 +16317,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16322,11 +16329,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16334,7 +16341,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16342,15 +16349,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16376,7 +16383,7 @@ var ts; } ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { - if (node.kind === 203 /* BindingElement */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && @@ -16390,11 +16397,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16405,7 +16412,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16432,7 +16439,7 @@ var ts; * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16458,11 +16465,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16480,7 +16487,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16488,7 +16495,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16496,8 +16503,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16519,17 +16526,13 @@ var ts; if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - var nameOrArgument = getNameOrArgument(initializer); - if (ts.isPrivateIdentifier(nameOrArgument)) { - ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -16563,7 +16566,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16588,14 +16591,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16614,23 +16617,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16667,17 +16670,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16689,14 +16692,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16707,12 +16710,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16720,7 +16723,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16733,18 +16736,18 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { - var _a, _b, _c; + var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: - return node.initializer.arguments[0].text; - case 266 /* ImportDeclaration */: - return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: - return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + case 254 /* SyntaxKind.VariableDeclaration */: + return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; + case 266 /* SyntaxKind.ImportDeclaration */: + return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); } @@ -16756,14 +16759,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16773,17 +16776,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16791,11 +16794,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16803,7 +16806,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16824,13 +16827,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16844,7 +16847,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16854,27 +16857,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16886,7 +16889,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16901,11 +16904,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16934,13 +16937,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16951,7 +16954,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16975,7 +16978,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -17041,7 +17044,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -17058,41 +17061,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17103,7 +17106,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17112,22 +17115,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17144,11 +17147,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17158,7 +17161,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17167,18 +17170,18 @@ var ts; ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17199,13 +17202,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17216,13 +17219,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17231,7 +17234,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17239,27 +17242,30 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - // Any name in an export specifier or JSX Attribute + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + // Any name in an export specifier or JSX Attribute or Jsx Element return true; } return false; @@ -17275,36 +17281,44 @@ var ts; // export = // export default // module.exports = - // {} - // {name: } + // module.exports.x = + // const x = require("...") + // const { x } = require("...") + // const x = require("...").y + // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 297 /* ShorthandPropertyAssignment */ || - node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { + return true; + } + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) + && ts.isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17323,7 +17337,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17340,7 +17354,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17349,7 +17363,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17362,7 +17376,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17389,11 +17403,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17401,7 +17415,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17420,7 +17434,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17433,38 +17447,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17474,7 +17488,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17491,7 +17505,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17501,19 +17515,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17526,10 +17540,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17545,11 +17559,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17564,7 +17578,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17573,11 +17587,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17585,15 +17599,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17612,58 +17626,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17842,129 +17856,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17974,9 +17988,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18091,9 +18105,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18108,8 +18122,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18139,13 +18153,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18164,13 +18178,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18187,6 +18201,10 @@ var ts; return indentStrings[1].length; } ts.getIndentSize = getIndentSize; + function isNightly() { + return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders"); + } + ts.isNightly = isNightly; function createTextWriter(newLine) { var output; var indent; @@ -18411,12 +18429,22 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; + /** + * This function is an inverse of `getDeclarationEmitExtensionForPath`. + */ + function getPossibleOriginalInputExtensionForExtension(path) { + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; + } + ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { return options.outFile || options.out; } @@ -18476,10 +18504,10 @@ var ts; return ts.combinePaths(newDirPath, sourceFilePath); } ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) { diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } ts.writeFile = writeFile; function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) { @@ -18542,7 +18570,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18552,11 +18580,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18567,10 +18595,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18590,10 +18618,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18642,7 +18670,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18759,7 +18787,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18834,7 +18862,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18846,11 +18874,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18867,23 +18895,23 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18895,16 +18923,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18929,22 +18957,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18964,14 +18992,14 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18983,22 +19011,22 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -19006,15 +19034,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -19022,7 +19050,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19035,14 +19063,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19054,8 +19082,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19065,33 +19093,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19122,10 +19150,15 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfAccessExpression(node) { + return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { return ts.isQualifiedName(node.parent) && node.parent.right === node || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -19133,12 +19166,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19154,7 +19187,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19325,9 +19358,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19470,8 +19503,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19495,32 +19528,32 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SyntaxKind.SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19529,11 +19562,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19548,47 +19581,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19658,9 +19691,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19671,11 +19704,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19722,44 +19755,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19767,7 +19800,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19777,31 +19810,66 @@ var ts; return expr; } ts.getLeftmostAccessExpression = getLeftmostAccessExpression; + function forEachNameInAccessChainWalkingLeft(name, action) { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + function walkAccessExpression(access) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { + if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { + var res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + // Chain interrupted by non-static-name access 'x[expr()].y.z' + return undefined; + } + } + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (ts.isIdentifier(access.expression)) { + // End of chain at Identifier 'x.y.z' + return action(access.expression); + } + // End of chain at non-Identifier 'x().y.z' + return undefined; + } + } + ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19835,9 +19903,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19846,8 +19914,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19855,8 +19923,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20051,7 +20119,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20060,43 +20128,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20106,16 +20174,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20124,7 +20192,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20156,15 +20224,15 @@ var ts; file.externalModuleIndicator = ts.isFileProbablyExternalModule(file); }; case ts.ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } var combined_1 = ts.or.apply(void 0, checks); @@ -20175,15 +20243,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20193,8 +20261,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -20219,7 +20287,7 @@ var ts; case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; default: @@ -20244,7 +20312,7 @@ var ts; return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; } @@ -20280,7 +20348,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20297,14 +20365,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20312,13 +20380,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20417,9 +20485,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20432,7 +20500,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20441,7 +20509,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20459,10 +20527,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20484,7 +20552,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20521,11 +20589,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20562,7 +20630,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20687,43 +20755,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20731,7 +20800,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20742,11 +20811,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20777,7 +20846,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20830,11 +20899,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20843,7 +20912,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20952,23 +21021,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20984,10 +21053,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21022,7 +21091,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21033,34 +21102,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21201,7 +21270,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21221,18 +21290,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return node.parent.decorators; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21240,45 +21309,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21290,7 +21359,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21308,7 +21377,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21317,7 +21386,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21356,7 +21425,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21376,42 +21445,47 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; + function getParameterTypeNode(parameter) { + var _a; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + } + ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); /* @internal */ var ts; @@ -21534,28 +21608,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21566,7 +21640,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21586,8 +21660,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21603,7 +21677,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21621,10 +21695,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21637,7 +21711,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21645,11 +21719,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21663,7 +21737,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21680,10 +21754,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21713,8 +21787,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21727,9 +21801,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21749,7 +21823,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21771,7 +21845,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21780,21 +21854,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21812,16 +21886,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21833,8 +21907,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21849,8 +21923,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21867,14 +21941,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21894,9 +21968,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22090,11 +22164,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22152,10 +22226,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22286,12 +22360,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22447,18 +22521,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22494,30 +22568,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22585,38 +22659,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22720,11 +22794,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22742,7 +22816,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) { @@ -22753,7 +22827,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseSignatureDeclaration(updated, original) { @@ -22765,9 +22839,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseFunctionLikeDeclaration(updated, original) { @@ -22801,7 +22875,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22814,21 +22888,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22837,7 +22911,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22848,19 +22922,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22870,10 +22944,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22892,8 +22966,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22905,9 +22979,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22917,25 +22991,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22943,9 +23017,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 8388608 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22955,51 +23029,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 33554432 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 8192 /* ContainsLexicalThis */; + transformFlags = 8192 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23012,23 +23086,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23040,34 +23114,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23075,7 +23149,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23092,12 +23166,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 65536 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23120,11 +23194,11 @@ var ts; name = modifiersOrName; constraint = nameOrConstraint; } - var node = createBaseNamedDeclaration(163 /* TypeParameter */, + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, /*decorators*/ undefined, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateTypeParameterDeclaration(node, modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { @@ -23150,22 +23224,22 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23183,12 +23257,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + 1 /* TransformFlags.ContainsTypeScript */ | + 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; return node; } // @api @@ -23202,11 +23276,11 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23220,18 +23294,18 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + 8388608 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23249,10 +23323,10 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23268,26 +23342,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -23307,11 +23381,11 @@ var ts; } // @api function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, decorators, modifiers, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @api @@ -23324,11 +23398,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23342,7 +23416,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(172 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -23358,7 +23432,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(173 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -23374,11 +23448,11 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23391,11 +23465,11 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23408,10 +23482,10 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23425,10 +23499,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23447,11 +23521,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23464,10 +23538,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23479,11 +23553,11 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23505,10 +23579,10 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23539,10 +23613,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23554,9 +23628,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23567,9 +23641,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23580,9 +23654,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23593,12 +23667,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23612,9 +23686,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23625,9 +23699,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23639,7 +23713,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23649,7 +23723,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23657,7 +23731,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23665,12 +23739,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23684,9 +23758,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23697,10 +23771,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23711,22 +23785,22 @@ var ts; : node; } function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertion; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; @@ -23741,9 +23815,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23754,18 +23828,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23776,10 +23850,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23791,14 +23865,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23814,9 +23888,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23830,16 +23904,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23851,12 +23925,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23867,21 +23941,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 16384 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23903,7 +23977,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23922,7 +23996,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23936,7 +24010,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -23948,8 +24022,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23965,13 +24039,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -23981,7 +24055,7 @@ var ts; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -23992,7 +24066,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -24002,8 +24076,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24019,8 +24093,8 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); @@ -24028,12 +24102,12 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24044,7 +24118,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24053,13 +24127,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 4194304 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24076,8 +24150,8 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); @@ -24087,18 +24161,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24108,7 +24182,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24116,9 +24190,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24132,7 +24206,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -24140,12 +24214,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24159,13 +24233,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24177,7 +24251,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24190,23 +24264,23 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24224,15 +24298,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24249,7 +24323,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24262,7 +24336,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24275,7 +24349,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24288,13 +24362,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24305,17 +24379,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24327,7 +24401,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24336,7 +24410,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24348,7 +24422,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24358,46 +24432,46 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) - return 32768 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return 32768 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24405,7 +24479,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24417,11 +24491,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24443,13 +24517,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24460,8 +24534,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24487,41 +24561,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 524288 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24533,12 +24607,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24549,8 +24623,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24566,17 +24640,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24588,13 +24662,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24606,11 +24680,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24624,33 +24698,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24668,13 +24742,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24686,8 +24760,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24695,7 +24769,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24709,12 +24783,12 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24727,11 +24801,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24744,7 +24818,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24764,7 +24838,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24781,7 +24855,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24798,7 +24872,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24821,7 +24895,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24841,7 +24915,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24851,9 +24925,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24867,11 +24941,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24882,11 +24956,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24897,13 +24971,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24914,7 +24988,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24931,7 +25005,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24948,7 +25022,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24965,7 +25039,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24978,7 +25052,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -24998,17 +25072,17 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25023,17 +25097,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25045,25 +25119,25 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } return node; @@ -25083,14 +25157,14 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25108,9 +25182,9 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25126,9 +25200,9 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25143,12 +25217,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -25162,21 +25236,21 @@ var ts; } // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */, decorators, modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */, decorators, modifiers); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -25190,7 +25264,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25203,7 +25277,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25216,10 +25290,10 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25230,13 +25304,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -25251,14 +25325,14 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25273,7 +25347,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25281,9 +25355,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25296,10 +25370,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25311,10 +25385,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25326,7 +25400,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25340,10 +25414,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25354,12 +25428,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25370,10 +25444,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25384,14 +25458,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25404,13 +25478,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25423,7 +25497,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -25431,7 +25505,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25447,10 +25521,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25461,14 +25535,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25481,7 +25555,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */, + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -25491,10 +25565,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25549,7 +25623,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -25566,7 +25640,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25580,7 +25654,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25592,7 +25666,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25621,7 +25695,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25638,7 +25712,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25656,7 +25730,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25677,7 +25751,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25698,7 +25772,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25716,7 +25790,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25731,13 +25805,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25751,7 +25825,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25763,7 +25837,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25780,7 +25854,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25793,7 +25867,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25806,7 +25880,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25878,7 +25952,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -25890,7 +25964,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -25902,7 +25976,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -25919,7 +25993,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -25927,7 +26001,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25940,7 +26014,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25948,9 +26022,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25964,7 +26038,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25972,9 +26046,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25988,11 +26062,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26003,7 +26077,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26011,7 +26085,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26024,10 +26098,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26039,25 +26113,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26069,11 +26143,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26084,11 +26158,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26099,13 +26173,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26119,7 +26193,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26136,7 +26210,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26149,16 +26223,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26173,7 +26247,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26186,7 +26260,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26201,7 +26275,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -26231,13 +26305,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -26263,12 +26337,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26282,13 +26356,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26303,7 +26377,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26320,7 +26394,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26359,7 +26433,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26374,7 +26448,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26392,28 +26466,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26424,7 +26498,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26432,7 +26506,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26447,7 +26521,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26461,12 +26535,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26489,7 +26563,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26506,7 +26580,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26517,14 +26591,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26546,12 +26620,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26665,11 +26739,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26695,7 +26769,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26716,20 +26790,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26737,7 +26811,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26746,11 +26820,11 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); } @@ -26817,9 +26891,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26838,7 +26912,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26851,7 +26925,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26864,7 +26938,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -26889,9 +26963,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -26908,7 +26982,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -26966,7 +27040,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27155,52 +27229,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27209,14 +27283,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27225,22 +27299,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 33562624 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27252,78 +27326,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 589443072 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 557748224 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 591310848 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537165824 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 536940544 /* ClassExcludes */; - case 171 /* Constructor */: - return 591306752 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 570433536 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 574529536 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 536973312 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536903680 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536887296 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return 536887296 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return 589443072 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return 536870912 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return 557748224 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return 591310848 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return 537165824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return 536940544 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return 591306752 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return 570433536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return 574529536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return 536973312 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return 536903680 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return 536887296 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return 536870912 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return 536870912 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return 536870912 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27333,7 +27407,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27396,50 +27470,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27467,22 +27541,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27510,7 +27584,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27579,7 +27653,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27621,7 +27695,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27630,7 +27704,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27662,7 +27736,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -27898,7 +27972,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -27921,8 +27995,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -27963,7 +28037,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -27998,7 +28072,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28014,7 +28088,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28068,13 +28142,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28087,7 +28161,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28177,13 +28251,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28590,7 +28664,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28599,741 +28673,741 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29341,176 +29415,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29530,7 +29604,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29709,14 +29783,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29755,7 +29829,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29780,14 +29854,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29795,7 +29869,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29824,8 +29898,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29841,26 +29915,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29868,7 +29942,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -29930,7 +30004,7 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -29975,10 +30049,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30097,7 +30171,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30109,11 +30183,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30145,12 +30219,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30168,7 +30242,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30183,7 +30257,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30198,7 +30272,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30213,21 +30287,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30248,29 +30322,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30281,68 +30355,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30350,21 +30424,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30497,7 +30571,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30578,7 +30652,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30598,9 +30672,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30612,14 +30686,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 93 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30631,7 +30705,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30647,20 +30721,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30668,9 +30742,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -30678,7 +30752,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30686,51 +30760,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.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 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30742,345 +30816,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.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 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31089,64 +31163,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31195,7 +31269,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31220,13 +31294,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31274,7 +31348,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31302,8 +31376,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31325,7 +31399,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31423,7 +31497,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31442,25 +31516,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31468,28 +31542,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31507,7 +31581,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31516,10 +31590,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31556,15 +31630,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31596,13 +31670,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31635,7 +31709,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31663,12 +31737,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31686,7 +31760,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31706,8 +31780,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31748,7 +31822,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -31775,16 +31849,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -31825,52 +31899,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -31971,15 +32045,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -31991,7 +32065,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -31999,31 +32073,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32061,7 +32135,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32076,17 +32150,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32096,7 +32170,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32121,24 +32195,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32149,7 +32223,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32216,24 +32290,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32250,7 +32324,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32262,11 +32336,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32290,23 +32364,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32319,23 +32393,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32348,12 +32422,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32381,23 +32455,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32405,9 +32479,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32418,18 +32492,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32438,50 +32512,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32493,42 +32567,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32537,7 +32611,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32554,8 +32628,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32570,51 +32644,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32634,7 +32708,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32642,7 +32716,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32708,7 +32782,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32731,38 +32805,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -32809,20 +32883,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -32831,8 +32905,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -32841,58 +32915,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -32913,7 +32987,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -32931,39 +33005,39 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` } } @@ -32978,11 +33052,12 @@ var ts; var startPos = scanner.getStartPos(); var result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -32992,13 +33067,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33027,7 +33102,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33045,18 +33120,18 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) { + function parseEntityName(allowReservedWords, diagnosticMessage) { var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; } dotPos = getNodePos(); - entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos); + entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos); } return entity; } @@ -33089,12 +33164,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33105,7 +33180,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33123,7 +33198,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33131,13 +33206,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33152,30 +33227,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33189,11 +33264,11 @@ var ts; } // TYPES function parseEntityNameOfTypeReference() { - return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected); + return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33203,14 +33278,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33248,12 +33323,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33265,8 +33340,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33274,9 +33349,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*decorators*/ undefined, @@ -33290,15 +33365,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33307,13 +33382,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33321,9 +33396,10 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true); - var typeArguments = tryParseTypeArguments(); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); + var entityName = parseEntityName(/*allowReservedWords*/ true); + // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. + var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } function parseTypeParameter() { @@ -33332,7 +33408,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33351,21 +33427,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33389,7 +33465,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33405,7 +33481,7 @@ var ts; // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), @@ -33419,11 +33495,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33433,16 +33509,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33464,11 +33540,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33487,17 +33563,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33506,20 +33582,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33539,7 +33615,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33558,21 +33634,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(decorators, modifiers, parameters, type); @@ -33580,14 +33656,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33596,7 +33672,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33604,10 +33680,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33617,7 +33693,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33628,30 +33704,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33660,16 +33736,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33680,9 +33756,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33691,51 +33767,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33748,10 +33824,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -33760,10 +33836,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33772,21 +33848,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33795,10 +33871,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -33808,34 +33884,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -33844,89 +33920,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -33934,48 +34010,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -33985,18 +34061,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34004,15 +34080,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34028,9 +34104,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34044,17 +34120,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34083,7 +34159,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34097,35 +34173,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34135,7 +34211,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34143,17 +34219,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34174,65 +34250,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34243,19 +34319,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34273,10 +34349,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34289,10 +34365,10 @@ var ts; setDecoratorContext(/*val*/ false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos); + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -34300,9 +34376,9 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) { + function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -34328,7 +34404,7 @@ var ts; // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -34342,12 +34418,12 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then @@ -34356,13 +34432,13 @@ var ts; // Note: we call reScanGreaterToken so that we get an appropriately merged token // for cases like `> > =` becoming `>>=` if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } // It wasn't an assignment or a lambda. This is a conditional expression: return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34398,8 +34474,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher()), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34407,8 +34483,8 @@ var ts; return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, disallowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -34418,14 +34494,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34433,53 +34509,53 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? - parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) : - tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); }); + return triState === 1 /* Tristate.True */ ? + parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } // True -> We definitely expect a parenthesized arrow function here. // False -> There *cannot* be a parenthesized arrow function here. // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34488,102 +34564,102 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - return 1 /* True */; + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function parsePossibleParenthesizedArrowFunctionExpression() { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction); + var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, asyncModifier); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); } } return undefined; @@ -34592,26 +34668,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity, disallowReturnTypeInArrowFunction) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34621,7 +34697,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34638,28 +34714,11 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - // Given: - // x ? y => ({ y }) : z => ({ z }) - // We try to parse the body of the first arrow function by looking at: - // ({ y }) : z => ({ z }) - // This is a valid arrow function with "z" as the return type. - // - // But, if we're in the true side of a conditional expression, this colon - // terminates the expression, so we cannot allow a return type if we aren't - // certain whether or not the preceding text was parsed as a parameter list. - // - // For example, - // a() ? (b: number, c?: string): void => d() : e - // is determined by isParenthesizedArrowFunctionExpression to unambiguously - // be an arrow expression, so we allow a return type. - if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) { - return undefined; - } - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34674,31 +34733,31 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) : parseIdentifier(); var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync, disallowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + function parseArrowFunctionExpressionBody(isAsync) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34715,28 +34774,28 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }) - : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } function parseConditionalExpressionRest(leftOperand, pos) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher() + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -34744,7 +34803,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -34773,16 +34832,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -34803,7 +34862,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -34831,7 +34890,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -34864,7 +34923,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -34881,10 +34940,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -34909,23 +34968,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -34948,18 +35007,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -34980,17 +35039,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35031,29 +35090,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35115,19 +35174,19 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35135,11 +35194,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35165,11 +35224,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35180,11 +35239,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35194,13 +35253,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35214,15 +35273,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35232,14 +35291,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35251,21 +35310,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35273,8 +35332,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35295,60 +35354,60 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : - scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* SyntaxKind.EqualsToken */ ? undefined : + scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35361,11 +35420,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35378,36 +35437,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35428,8 +35487,8 @@ var ts; } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35438,7 +35497,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35449,30 +35508,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35487,14 +35546,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35503,7 +35562,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35511,9 +35570,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35526,7 +35585,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35534,22 +35593,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(31 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35562,58 +35621,34 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` - // These tokens can't follow in a call expression, nor can they start an - // expression. So, consider the type argument list part of an instantiation - // expression. - // falls through - case 27 /* CommaToken */: // foo, - case 24 /* DotToken */: // foo. - case 28 /* QuestionDotToken */: // foo?. - case 21 /* CloseParenToken */: // foo) - case 23 /* CloseBracketToken */: // foo] - case 58 /* ColonToken */: // foo: - case 26 /* SemicolonToken */: // foo; - case 57 /* QuestionToken */: // foo? - case 34 /* EqualsEqualsToken */: // foo == - case 36 /* EqualsEqualsEqualsToken */: // foo === - case 35 /* ExclamationEqualsToken */: // foo != - case 37 /* ExclamationEqualsEqualsToken */: // foo !== - case 55 /* AmpersandAmpersandToken */: // foo && - case 56 /* BarBarToken */: // foo || - case 60 /* QuestionQuestionToken */: // foo ?? - case 52 /* CaretToken */: // foo ^ - case 50 /* AmpersandToken */: // foo & - case 51 /* BarToken */: // foo | - case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; } - // Treat anything else as an expression. - return false; + // Consider something a type argument list only if the following token can't start an expression. + return !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35621,21 +35656,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35643,21 +35678,21 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); + var expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -35665,34 +35700,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { + var expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35701,18 +35736,18 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); - var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }) : undefined; + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); + var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful. node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); - var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); + parseExpected(58 /* SyntaxKind.ColonToken */); + var initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker @@ -35725,10 +35760,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35742,17 +35777,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -35763,20 +35798,20 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -35784,13 +35819,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -35803,9 +35838,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -35814,7 +35849,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -35826,58 +35861,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -35885,26 +35920,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { - var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); - parseExpected(21 /* CloseParenToken */); + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { + var expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35912,10 +35947,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35923,7 +35958,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -35931,47 +35966,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -35980,7 +36015,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36000,25 +36035,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36030,7 +36065,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36041,9 +36076,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36064,25 +36099,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36105,44 +36140,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36155,51 +36190,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36209,7 +36244,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36218,68 +36253,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36288,7 +36323,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -36311,16 +36346,16 @@ var ts; if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { var node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -36329,33 +36364,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36364,7 +36399,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36375,10 +36410,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* SyntaxKind.OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -36387,26 +36422,26 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36414,29 +36449,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36449,8 +36484,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36462,13 +36497,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36484,19 +36519,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36509,27 +36544,27 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36540,9 +36575,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); // Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker. node.typeParameters = typeParameters; @@ -36552,11 +36587,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36564,20 +36599,20 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); @@ -36585,21 +36620,21 @@ var ts; function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 173 /* SetAccessor */) + if (type && node.kind === 173 /* SyntaxKind.SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36616,7 +36651,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36626,24 +36661,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36657,7 +36692,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); } @@ -36672,7 +36707,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36685,7 +36720,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36702,17 +36737,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -36733,7 +36768,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -36741,33 +36776,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -36779,17 +36814,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36797,21 +36832,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -36819,17 +36854,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36845,45 +36880,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -36892,11 +36927,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36913,12 +36948,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -36929,9 +36964,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -36941,10 +36976,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36952,17 +36987,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -36973,37 +37008,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37013,7 +37048,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37021,7 +37056,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37035,15 +37070,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37052,21 +37087,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); - var value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37080,15 +37115,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -37106,26 +37141,26 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37141,8 +37176,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37155,17 +37190,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37190,10 +37225,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37228,15 +37263,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37256,26 +37291,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37287,13 +37322,13 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -37337,11 +37372,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37353,10 +37388,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37365,16 +37400,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); - var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); - while (token() === 80 /* PrivateIdentifier */) { + var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37382,9 +37417,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37394,9 +37429,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37444,7 +37479,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37457,16 +37492,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37474,35 +37509,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37510,10 +37545,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37532,7 +37567,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37561,26 +37596,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37588,14 +37623,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37603,7 +37638,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37652,7 +37687,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37690,7 +37725,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37705,31 +37740,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -37741,8 +37776,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37756,32 +37791,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -37798,7 +37833,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -37810,17 +37845,17 @@ var ts; // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false) + ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -37831,8 +37866,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -37860,35 +37895,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -37904,12 +37939,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -37920,12 +37955,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -37946,8 +37981,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -37969,14 +38004,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -37995,21 +38030,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38043,7 +38078,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38060,7 +38095,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38084,11 +38119,11 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38100,7 +38135,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38111,9 +38146,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38122,7 +38157,8 @@ var ts; if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + var end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -38137,18 +38173,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38156,26 +38192,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38183,15 +38219,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38203,7 +38239,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38211,9 +38247,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38230,7 +38266,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38245,7 +38281,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38258,16 +38294,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38275,7 +38311,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38292,7 +38328,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38447,9 +38483,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38704,7 +38740,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -38719,7 +38755,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -38757,7 +38793,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -38810,7 +38846,7 @@ var ts; })(IncrementalParser || (IncrementalParser = {})); /** @internal */ function isDeclarationFileName(fileName) { - return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]); + return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions); } ts.isDeclarationFileName = isDeclarationFileName; function parseResolutionMode(mode, pos, end, reportDiagnostic) { @@ -38937,18 +38973,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -38982,15 +39018,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39033,10 +39069,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39056,11 +39092,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39131,6 +39167,7 @@ var ts; ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -39363,18 +39400,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39383,7 +39420,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; var commandOptionsWithoutBuild = [ // CommandLine only options @@ -39466,7 +39503,7 @@ var ts; es2020: ts.ModuleKind.ES2020, es2022: ts.ModuleKind.ES2022, esnext: ts.ModuleKind.ESNext, - node12: ts.ModuleKind.Node12, + node16: ts.ModuleKind.Node16, nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -39641,15 +39678,15 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -39820,7 +39857,7 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, - node12: ts.ModuleResolutionKind.Node12, + node16: ts.ModuleResolutionKind.Node16, nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -40063,8 +40100,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, @@ -40296,7 +40333,7 @@ var ts; affectsModuleResolution: true, description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: ts.Diagnostics.Language_and_Environment, - defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; /* @internal */ @@ -40417,7 +40454,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40442,8 +40479,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40502,11 +40539,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40535,14 +40572,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40553,7 +40590,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -40888,7 +40925,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -40928,7 +40965,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -40995,16 +41032,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41019,16 +41056,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41045,7 +41082,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41237,10 +41274,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41291,19 +41328,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41312,25 +41349,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41385,7 +41422,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -41730,8 +41767,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -41972,11 +42009,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42120,7 +42157,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42154,13 +42191,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42183,7 +42220,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42261,7 +42298,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42318,7 +42355,8 @@ var ts; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; - Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; + Extensions[Extensions["TsOnly"] = 5] = "TsOnly"; })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -42328,7 +42366,7 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { var _a; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -42336,7 +42374,8 @@ var ts; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations: failedLookupLocations + failedLookupLocations: failedLookupLocations, + resolutionDiagnostics: diagnostics }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -42413,7 +42452,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42476,7 +42515,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -42531,13 +42570,24 @@ var ts; // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions }; + var diagnostics = []; + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -42556,7 +42606,7 @@ var ts; isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); @@ -42622,7 +42672,7 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getDefaultNodeResolutionFeatures(options) { - return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -42639,6 +42689,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ts.emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: ts.noop }; return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { @@ -42681,7 +42733,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -42832,7 +42884,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -42867,7 +42919,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -42980,8 +43032,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -43001,8 +43053,8 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ts.ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ts.ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ts.ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43014,10 +43066,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43220,7 +43272,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43236,15 +43288,15 @@ var ts; // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; - NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default"; + NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default"; NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault"; NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); - function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { - return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); } function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43263,15 +43315,34 @@ var ts; return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + var extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) + extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) + extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). + var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + var diagnostics = []; var state = { compilerOptions: compilerOptions, host: host, @@ -43279,10 +43350,12 @@ var ts; failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -43342,7 +43415,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43409,7 +43482,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43428,7 +43501,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43445,7 +43518,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43455,9 +43528,9 @@ var ts; } } function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) { var result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; + return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } @@ -43473,53 +43546,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: + case Extensions.TsOnly: + var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43578,6 +43653,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features: features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: ts.noop }; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); @@ -43664,6 +43741,8 @@ var ts; packageJsonInfoCache: packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: ts.noop }; var parts = ts.getPathComponents(fileName); parts.pop(); @@ -43727,6 +43806,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -43799,14 +43879,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; + case Extensions.TsOnly: + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -43843,7 +43925,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -43952,7 +44034,6 @@ var ts; function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { return loadModuleFromTargetImportOrExport; function loadModuleFromTargetImportOrExport(target, subpath, pattern) { - var _a, _b; if (typeof target === "string") { if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { if (state.traceEnabled) { @@ -43989,13 +44070,16 @@ var ts; } return toSearchResult(/*value*/ undefined); } - var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) + return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); } else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null if (!Array.isArray(target)) { - for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { - var key = _c[_i]; + for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) { + var key = _a[_i]; if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { var subTarget = target[key]; var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); @@ -44013,8 +44097,8 @@ var ts; } return toSearchResult(/*value*/ undefined); } - for (var _d = 0, target_2 = target; _d < target_2.length; _d++) { - var elem = target_2[_d]; + for (var _b = 0, target_2 = target; _b < target_2.length; _b++) { + var elem = target_2[_b]; var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); if (result) { return result; @@ -44032,6 +44116,128 @@ var ts; trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(/*value*/ undefined); + function toAbsolutePath(path) { + var _a, _b; + if (path === undefined) + return path; + return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a))); + } + function combineDirectoryPath(root, dir) { + return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir)); + } + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) { + var _a, _b, _c, _d; + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames }); + var commonSourceDirGuesses = []; + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory + var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts")); + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + var fragment = ts.ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + var parts = ts.getPathComponents(fragment); + parts.pop(); // remove a directory + var commonDir_1 = ts.getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir_1); + fragment = ts.ensureTrailingDirectorySeparator(commonDir_1); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(ts.createCompilerDiagnostic(isImports + ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath)); + } + for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) { + var commonSourceDirGuess = commonSourceDirGuesses_1[_i]; + var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) { + var candidateDir = candidateDirectories_1[_e]; + if (ts.startsWith(finalPath, candidateDir)) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator + var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; + for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { + var ext = jsAndDtsExtensions_1[_f]; + if (ts.fileExtensionIs(possibleInputBase, ext)) { + var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) { + var possibleExt = inputExts_1[_g]; + var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state))); + } + } + } + } + } + } + } + } + return undefined; + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) { + var _a, _b; + // Config file ouput paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess; + var candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } /* @internal */ @@ -44179,7 +44385,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44222,11 +44428,12 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -44269,9 +44476,10 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; /** @@ -44297,14 +44505,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44315,34 +44523,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44350,21 +44558,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44372,16 +44580,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -44401,7 +44609,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -44412,7 +44620,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -44486,8 +44694,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -44509,7 +44717,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -44536,7 +44744,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -44556,33 +44764,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -44608,36 +44816,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(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; @@ -44656,14 +44864,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -44690,11 +44898,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -44706,20 +44914,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -44739,7 +44947,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -44747,9 +44955,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -44762,7 +44970,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -44776,9 +44984,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -44802,11 +45010,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -44833,7 +45041,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -44866,21 +45074,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -44888,22 +45096,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -44911,21 +45119,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -44939,10 +45147,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -44952,8 +45160,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -44976,59 +45184,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45038,47 +45246,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45092,22 +45300,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45115,7 +45323,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45131,7 +45339,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45142,68 +45350,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45215,7 +45423,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45227,7 +45435,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45242,28 +45450,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45273,7 +45481,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45292,8 +45500,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45307,7 +45515,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45358,12 +45566,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45385,7 +45593,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -45402,7 +45610,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -45473,7 +45681,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -45507,7 +45715,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -45536,7 +45744,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -45555,9 +45763,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -45581,7 +45789,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -45590,12 +45798,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -45603,16 +45811,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -45620,7 +45828,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -45631,15 +45839,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -45649,14 +45857,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -45705,9 +45913,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -45724,7 +45932,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -45738,7 +45946,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -45749,10 +45957,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -45777,7 +45985,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -45805,7 +46013,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -45834,7 +46042,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -45846,28 +46054,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -45893,8 +46101,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -45932,76 +46140,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46018,9 +46226,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46034,46 +46242,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46100,17 +46308,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46118,25 +46326,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46144,8 +46352,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46155,10 +46363,10 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } @@ -46172,7 +46380,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */ || prop.name.kind !== 79 /* SyntaxKind.Identifier */) { continue; } var identifier = prop.name; @@ -46184,9 +46392,9 @@ 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 === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + var currentKind = prop.kind === 296 /* SyntaxKind.PropertyAssignment */ || prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || prop.kind === 169 /* SyntaxKind.MethodDeclaration */ + ? 1 /* ElementKind.Property */ + : 2 /* ElementKind.Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -46194,17 +46402,17 @@ var ts; } } } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46212,10 +46420,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46241,9 +46449,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46254,8 +46462,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46263,29 +46471,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46303,24 +46511,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46362,7 +46570,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46373,7 +46581,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -46412,10 +46620,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -46425,7 +46633,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -46441,7 +46649,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -46454,7 +46662,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -46512,11 +46720,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -46526,7 +46734,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -46574,7 +46782,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -46583,28 +46791,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -46616,28 +46824,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -46648,94 +46856,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -46745,73 +46953,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -46822,27 +47030,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -46862,28 +47070,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -46902,13 +47110,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -46919,15 +47127,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -46948,13 +47156,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -46966,11 +47174,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -46984,17 +47192,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47003,19 +47211,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47023,7 +47231,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47032,10 +47240,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47054,7 +47262,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47075,7 +47283,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47087,7 +47295,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47100,7 +47308,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47118,13 +47326,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47138,7 +47346,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47150,12 +47358,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47165,27 +47373,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -47204,7 +47412,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47219,7 +47427,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47264,12 +47472,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47285,7 +47493,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47298,19 +47506,19 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47322,72 +47530,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -47401,45 +47609,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -47453,9 +47661,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -47479,17 +47687,17 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } @@ -47574,32 +47782,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -47688,7 +47896,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -47822,24 +48030,24 @@ var ts; TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = new ts.Map(ts.getEntries({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ + string: 1 /* TypeFacts.TypeofEQString */, + number: 2 /* TypeFacts.TypeofEQNumber */, + bigint: 4 /* TypeFacts.TypeofEQBigInt */, + boolean: 8 /* TypeFacts.TypeofEQBoolean */, + symbol: 16 /* TypeFacts.TypeofEQSymbol */, + undefined: 65536 /* TypeFacts.EQUndefined */, + object: 32 /* TypeFacts.TypeofEQObject */, + function: 64 /* TypeFacts.TypeofEQFunction */ })); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -47945,10 +48153,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -47973,8 +48181,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -47989,7 +48197,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48023,7 +48231,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48037,20 +48245,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48102,10 +48310,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48200,7 +48408,7 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); @@ -48221,13 +48429,13 @@ var ts; getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48313,7 +48521,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48350,10 +48558,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -48424,32 +48632,32 @@ var ts; var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var nonInferrableAnyType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 65536 /* ObjectFlags.ContainsWideningType */); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -48459,27 +48667,28 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonInferrableType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48487,7 +48696,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48495,11 +48704,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -48647,7 +48856,7 @@ var ts; var enumRelation = new ts.Map(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -48658,7 +48867,7 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; @@ -48804,7 +49013,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -48818,44 +49027,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -48887,13 +49096,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -48901,7 +49110,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -48924,7 +49133,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -48933,8 +49142,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -48945,9 +49154,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -48990,7 +49199,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49032,7 +49241,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49041,7 +49250,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49056,9 +49265,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49091,7 +49300,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49101,17 +49310,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49131,8 +49340,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49146,7 +49355,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49160,17 +49369,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49184,7 +49393,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49200,19 +49409,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49227,9 +49436,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49257,7 +49466,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49272,7 +49481,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49295,19 +49504,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49332,7 +49541,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49347,30 +49556,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -49423,35 +49632,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -49466,17 +49675,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -49496,13 +49705,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -49511,12 +49720,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -49526,20 +49735,20 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -49554,7 +49763,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -49562,11 +49771,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -49582,39 +49791,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -49622,7 +49831,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -49631,7 +49840,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -49646,20 +49855,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -49667,7 +49876,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -49675,8 +49884,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -49701,7 +49910,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -49738,7 +49947,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -49765,7 +49974,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -49788,22 +49997,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -49815,10 +50024,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -49832,31 +50041,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -49869,7 +50078,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -49913,7 +50122,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -49925,10 +50134,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -49938,9 +50147,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -49959,9 +50168,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -49972,20 +50181,20 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50007,7 +50216,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50024,15 +50233,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50042,29 +50251,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50085,13 +50294,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50116,22 +50325,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { @@ -50145,7 +50354,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50158,7 +50367,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50170,14 +50379,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50187,7 +50396,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -50204,7 +50413,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50236,7 +50445,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50244,7 +50453,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50272,12 +50481,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50321,7 +50530,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50336,7 +50545,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50344,7 +50553,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50360,7 +50569,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50369,7 +50578,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -50378,7 +50587,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -50399,7 +50608,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -50416,7 +50625,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -50496,7 +50705,7 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -50508,7 +50717,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -50516,31 +50725,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -50551,38 +50760,38 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol) { var links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } return undefined; @@ -50625,7 +50834,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -50633,7 +50842,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -50644,7 +50853,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -50665,7 +50874,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -50688,22 +50897,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -50713,7 +50922,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -50734,9 +50943,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -50744,9 +50953,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -50780,7 +50989,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -50788,8 +50997,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -50803,8 +51012,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -50824,7 +51033,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -50845,7 +51054,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -50876,7 +51085,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -50936,7 +51145,7 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; @@ -50945,9 +51154,6 @@ var ts; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) { - error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -51000,7 +51206,7 @@ var ts; var tsExtension = ts.tryExtractTSExtension(moduleReference); var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 || moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -51011,27 +51217,27 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); var suggestedExt = (_h = suggestedExtensions.find(function (_a) { var actualExt = _a[0], _importExt = _a[1]; return host.fileExists(absoluteRef_1 + actualExt); })) === null || _h === void 0 ? void 0 : _h[1]; if (suggestedExt) { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -51063,27 +51269,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51097,7 +51303,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51116,12 +51322,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51153,7 +51359,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51205,15 +51411,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51228,7 +51434,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51263,7 +51469,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51352,21 +51558,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -51390,7 +51596,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -51411,7 +51617,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -51419,7 +51625,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -51429,7 +51635,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -51453,16 +51659,16 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol)); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && !getTypeOnlyAliasDeclaration(symbol)); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -51485,7 +51691,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -51499,7 +51705,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -51509,11 +51715,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -51545,14 +51751,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -51570,12 +51776,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -51584,9 +51790,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -51597,7 +51803,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -51616,7 +51822,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -51627,7 +51833,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -51671,9 +51877,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -51681,7 +51887,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -51725,7 +51931,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -51740,10 +51946,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -51754,16 +51960,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -51793,7 +51999,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -51817,14 +52023,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -51853,7 +52059,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -51862,28 +52068,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -51891,24 +52097,24 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + else if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement && ts.isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); @@ -51932,83 +52138,83 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52016,7 +52222,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52034,17 +52240,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 814775659 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52078,12 +52284,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52105,7 +52311,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52140,62 +52346,62 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52209,66 +52415,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52278,19 +52484,19 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52307,8 +52513,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52316,43 +52522,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52360,39 +52566,63 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); + var name = typeParameterToName(newParam, context); + var newTypeVariable = ts.factory.createTypeReferenceNode(name); + context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var saveInferTypeParameters_1 = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters_1; + var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive + // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType + // inner conditional runs the check the user provided on the check type (distributively) and returns the result + // checkType extends infer T ? T extends checkType ? T extends extendsType ? trueType : falseType : never : never; + // this is potentially simplifiable to + // checkType extends infer T ? T extends checkType & extendsType ? trueType : falseType : never; + // but that may confuse users who read the output more. + // On the other hand, + // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; + // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); + } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -52403,7 +52633,7 @@ var ts; return typeToTypeNodeHelper(type, context); } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -52411,27 +52641,27 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -52440,16 +52670,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */ && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -52458,7 +52688,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -52474,26 +52704,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -52505,7 +52735,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -52564,20 +52794,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -52586,8 +52816,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -52599,27 +52829,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -52627,7 +52857,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -52635,23 +52865,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -52675,8 +52905,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -52688,8 +52918,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -52753,17 +52983,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -52773,16 +53003,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -52793,10 +53023,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -52806,19 +53036,19 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; - if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { + if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* CheckFlags.Late */ && isLateBoundName(propertySymbol.escapedName)) { if (propertySymbol.declarations) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { @@ -52841,12 +53071,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -52860,12 +53090,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -52874,11 +53104,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -52897,12 +53127,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -52911,7 +53141,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -52936,7 +53166,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -52971,22 +53201,22 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -52994,7 +53224,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); var thisParameter = tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); @@ -53002,11 +53232,11 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53017,28 +53247,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53062,7 +53292,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53076,29 +53306,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */); - } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -53118,7 +53345,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53127,9 +53354,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53139,8 +53366,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53150,7 +53377,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -53169,8 +53396,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -53189,7 +53416,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53219,7 +53446,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53234,11 +53461,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53258,11 +53485,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53314,7 +53541,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53322,8 +53549,8 @@ var ts; return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier; } 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 - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53332,7 +53559,7 @@ var ts; var targetFile = ts.getSourceFileOfModule(chain[0]); var specifier = void 0; var assertion = void 0; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) { specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext); @@ -53344,9 +53571,9 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -53405,16 +53632,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -53433,7 +53660,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -53445,7 +53672,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -53458,9 +53685,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -53469,23 +53696,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -53502,7 +53729,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -53510,13 +53737,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -53528,38 +53755,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -53588,7 +53815,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -53598,8 +53825,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -53633,7 +53860,7 @@ var ts; return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -53645,7 +53872,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_6) { return result_6; @@ -53654,20 +53881,30 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; return result; } + function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { + var typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; + } + return false; + } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -53686,20 +53923,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -53717,17 +53954,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -53741,11 +53978,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -53762,16 +53999,16 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -53780,7 +54017,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -53795,17 +54032,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -53836,8 +54073,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -53850,10 +54087,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -53868,16 +54105,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -53894,7 +54131,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -53910,9 +54147,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54008,11 +54245,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54065,37 +54302,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54107,21 +54344,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54133,14 +54370,14 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -54166,7 +54403,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -54174,11 +54411,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -54191,20 +54428,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54213,18 +54450,18 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54237,7 +54474,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54251,23 +54488,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54283,14 +54520,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54301,10 +54538,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); @@ -54313,7 +54550,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54326,7 +54563,7 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); @@ -54334,7 +54571,7 @@ var ts; var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -54350,12 +54587,12 @@ var ts; })))]); addResult(ts.factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { addResult(ts.factory.createEnumDeclaration( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -54367,22 +54604,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -54416,7 +54653,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -54437,15 +54674,15 @@ var ts; var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -54494,7 +54731,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -54521,17 +54758,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -54574,15 +54811,15 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -54590,19 +54827,19 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -54613,7 +54850,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, @@ -54622,30 +54859,30 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -54653,21 +54890,21 @@ var ts; // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -54676,9 +54913,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -54686,16 +54923,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -54710,18 +54947,18 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -54736,7 +54973,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -54750,7 +54987,7 @@ var ts; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -54766,7 +55003,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -54781,17 +55018,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -54811,11 +55048,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -54826,25 +55063,25 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -54853,8 +55090,8 @@ var ts; /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); @@ -54863,19 +55100,19 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -54885,7 +55122,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -54894,7 +55131,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -54902,13 +55139,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -54929,7 +55166,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -54965,15 +55202,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -54983,22 +55220,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55016,7 +55253,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55025,17 +55262,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55054,14 +55291,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55071,10 +55308,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55086,25 +55323,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55112,27 +55349,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55144,9 +55381,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55160,9 +55397,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55175,17 +55412,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -55202,84 +55439,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55288,11 +55525,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55316,7 +55553,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55365,23 +55602,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -55398,12 +55635,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -55428,28 +55665,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -55457,9 +55694,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -55474,7 +55711,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -55489,15 +55726,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -55533,34 +55770,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -55571,18 +55808,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -55599,7 +55836,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -55607,7 +55844,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -55619,7 +55856,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -55633,9 +55870,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 32768 /* TypeFlags.Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -55646,11 +55883,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -55661,11 +55898,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -55687,11 +55924,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -55703,8 +55940,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -55722,7 +55959,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -55745,14 +55982,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -55781,7 +56018,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -55803,7 +56040,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -55863,7 +56100,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -55902,7 +56139,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -55932,12 +56169,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -55961,7 +56198,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56017,13 +56254,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56035,7 +56272,7 @@ var ts; var _a; var exportedMember = members_4.get(name); if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56068,9 +56305,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56082,16 +56319,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56111,7 +56348,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56129,7 +56366,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56139,11 +56376,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56153,7 +56390,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56161,18 +56398,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56186,7 +56423,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -56200,7 +56437,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56210,14 +56447,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56234,7 +56471,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56258,14 +56495,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56306,15 +56543,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56333,7 +56570,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56347,10 +56584,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -56373,7 +56610,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -56382,7 +56619,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -56407,11 +56644,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -56446,10 +56683,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -56464,8 +56701,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -56486,21 +56723,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -56508,13 +56745,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -56535,7 +56772,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -56556,7 +56793,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -56569,7 +56806,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -56578,7 +56815,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -56589,15 +56826,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -56605,56 +56842,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -56677,7 +56914,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -56688,46 +56925,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -56738,7 +56975,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -56751,9 +56988,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -56770,7 +57007,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -56781,10 +57018,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -56797,7 +57034,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -56820,7 +57057,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -56828,7 +57065,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -56837,13 +57074,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -56883,19 +57120,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -56905,7 +57142,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -56916,26 +57153,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -56960,7 +57197,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -56985,7 +57222,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -56993,15 +57230,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57041,8 +57278,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57050,8 +57287,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57065,7 +57302,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57079,8 +57316,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57101,7 +57338,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57120,7 +57357,7 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { @@ -57135,7 +57372,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57143,19 +57380,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57170,11 +57407,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -57183,23 +57420,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57211,15 +57448,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57245,22 +57482,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57272,22 +57509,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57313,7 +57550,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57329,14 +57566,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -57373,8 +57610,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -57383,7 +57620,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -57402,9 +57639,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -57429,10 +57666,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -57443,7 +57680,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -57452,7 +57689,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -57501,7 +57738,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -57510,10 +57747,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -57531,9 +57768,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -57559,10 +57796,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -57578,8 +57815,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -57589,7 +57826,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -57606,7 +57843,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -57614,7 +57851,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -57650,8 +57887,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -57686,7 +57923,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -57696,24 +57933,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -57725,7 +57962,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -57738,10 +57975,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -57749,11 +57986,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -57768,7 +58005,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -57931,12 +58168,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -57958,11 +58195,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -57987,8 +58224,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -57996,7 +58233,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58011,7 +58248,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58033,7 +58270,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58043,7 +58280,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58082,18 +58319,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58106,7 +58343,8 @@ var ts; if (symbol === globalThisSymbol) { var varsOnly_1 = new ts.Map(); members.forEach(function (p) { - if (!(p.flags & 418 /* BlockScoped */)) { + var _a; + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58115,10 +58353,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58134,8 +58372,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58144,16 +58382,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58171,20 +58409,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58205,11 +58443,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58219,29 +58457,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58261,7 +58499,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58289,13 +58527,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58308,12 +58546,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58321,7 +58559,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58331,8 +58569,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -58358,7 +58596,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -58366,8 +58604,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -58383,20 +58621,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -58404,34 +58642,34 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -58439,7 +58677,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -58448,7 +58686,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58472,7 +58710,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -58482,13 +58720,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -58507,7 +58745,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -58526,9 +58764,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -58589,7 +58827,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -58607,11 +58845,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -58621,7 +58859,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { hasDisjointDomainType = true; } } @@ -58633,7 +58871,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -58643,11 +58881,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -58672,7 +58910,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -58682,13 +58920,14 @@ var ts; // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of // nesting, so it is effectively just a safety stop. - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + var identity_1 = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) { + stack.push(identity_1); result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -58708,13 +58947,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -58734,23 +58973,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -58761,11 +59000,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -58824,7 +59063,7 @@ var ts; var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -58832,7 +59071,7 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !objectType.declaration.questionToken && !objectType.declaration.nameType); } @@ -58842,17 +59081,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ScriptTarget.ES2020 */) : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ScriptTarget.ES2015 */) : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -58867,21 +59106,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -58894,7 +59133,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -58912,41 +59151,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -58988,18 +59227,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59012,7 +59251,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59046,7 +59285,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59055,15 +59294,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59073,7 +59312,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59084,23 +59323,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59115,7 +59354,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59135,15 +59374,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -59186,13 +59425,13 @@ var ts; } function isApplicableIndexType(source, target) { // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index - // signature applies to types assignable to 'number' and numeric string literal types. + // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59243,17 +59482,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59268,7 +59507,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59286,7 +59525,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59335,7 +59574,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59347,7 +59586,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -59357,19 +59596,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -59381,25 +59620,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -59421,7 +59660,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -59430,7 +59669,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -59463,7 +59702,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -59475,18 +59714,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -59558,26 +59797,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -59604,7 +59843,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -59614,12 +59853,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -59628,7 +59867,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -59722,8 +59961,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -59737,7 +59976,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -59755,7 +59994,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -59770,8 +60009,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -59782,13 +60021,13 @@ var ts; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -59813,27 +60052,27 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -59858,10 +60097,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -59870,7 +60109,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -59898,7 +60137,7 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -59912,13 +60151,13 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; @@ -59940,7 +60179,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -59951,13 +60190,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -59992,14 +60231,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60030,12 +60269,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60070,9 +60309,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60084,21 +60323,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60120,10 +60359,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60131,14 +60370,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60154,7 +60393,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60165,22 +60404,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -60190,27 +60429,41 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); } } + // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the + // template type XXX, K has an added constraint of number | `${number}`. + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { + var mappedType = getTypeFromTypeNode(parent); + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + var typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + var constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = ts.append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60266,7 +60519,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60278,13 +60531,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60325,9 +60578,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60337,7 +60590,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -60348,13 +60601,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -60390,9 +60643,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -60457,7 +60710,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -60495,20 +60748,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -60517,14 +60770,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -60533,18 +60786,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -60553,28 +60806,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -60587,33 +60840,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -60631,7 +60884,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -60641,8 +60894,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -60650,8 +60903,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -60661,7 +60914,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -60679,26 +60932,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -60717,10 +60970,10 @@ var ts; var _loop_15 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -60735,7 +60988,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -60750,12 +61003,12 @@ var ts; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -60765,13 +61018,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -60823,19 +61076,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -60869,18 +61122,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -60894,20 +61147,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -60925,11 +61178,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -60943,7 +61196,7 @@ var ts; var _loop_16 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; @@ -60953,17 +61206,17 @@ var ts; } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -60982,7 +61235,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -60991,37 +61244,37 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; @@ -61045,11 +61298,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61058,8 +61311,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61096,20 +61349,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61120,41 +61373,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -61172,10 +61425,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -61188,10 +61441,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61205,11 +61458,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61226,7 +61479,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61238,7 +61491,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61247,7 +61500,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61276,12 +61529,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61310,37 +61563,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { + if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -61352,21 +61605,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -61378,8 +61631,8 @@ var ts; var constituents = getCrossProductIntersections(typeSet); // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions). - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -61390,12 +61643,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -61408,7 +61661,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -61416,7 +61669,7 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; @@ -61430,13 +61683,13 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -61468,7 +61721,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -61484,8 +61737,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -61505,12 +61758,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -61522,11 +61775,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -61536,14 +61789,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -61561,16 +61814,16 @@ var ts; function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) + return type.flags & 1048576 /* TypeFlags.Union */ ? isPossiblyReducibleByInstantiation(type) ? getIndexTypeForGenericType(type, stringsOnly) : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -61581,21 +61834,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -61612,7 +61865,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -61631,10 +61884,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -61645,13 +61898,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -61664,7 +61917,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -61677,35 +61930,35 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -61713,13 +61966,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -61740,16 +61993,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -61764,26 +62017,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -61793,7 +62046,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -61801,12 +62054,12 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -61818,33 +62071,33 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -61852,21 +62105,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -61888,20 +62141,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -61918,10 +62171,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -61939,62 +62192,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62019,7 +62272,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62033,17 +62286,20 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } } - // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where + // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P. + // For example, for an index access { [P in K]: Box }[X], we construct the type Box. + if (isGenericMappedType(objectType)) { + var nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + } } return type[cache] = type; } @@ -62053,19 +62309,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62075,7 +62331,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62083,12 +62339,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62099,33 +62355,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -62137,12 +62393,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -62158,11 +62414,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -62170,8 +62426,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -62181,7 +62437,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -62193,11 +62449,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62262,7 +62518,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62280,7 +62536,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62296,15 +62552,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -62322,7 +62578,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -62333,7 +62589,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -62361,14 +62617,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -62396,7 +62652,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -62419,7 +62675,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -62462,7 +62718,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -62475,7 +62731,7 @@ var ts; var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references @@ -62498,7 +62754,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -62512,7 +62768,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -62528,7 +62784,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -62541,7 +62797,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -62550,13 +62806,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -62576,13 +62832,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62591,7 +62847,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -62601,31 +62857,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -62635,7 +62891,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -62649,7 +62905,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -62664,11 +62920,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -62681,23 +62937,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62715,7 +62971,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -62726,39 +62982,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -62768,9 +63024,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -62786,20 +63042,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -62821,17 +63077,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -62847,99 +63103,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -62977,9 +63233,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -62988,22 +63244,22 @@ var ts; } } return type; - case 2 /* Function */: + case 2 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 3 /* TypeMapKind.Composite */: + case 4 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 3 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return { kind: 0 /* TypeMapKind.Simple */, source: source, target: target }; } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return { kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }; } function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + return { kind: 2 /* TypeMapKind.Function */, func: func }; } function makeCompositeTypeMapper(kind, mapper1, mapper2) { return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; @@ -63019,16 +63275,16 @@ var ts; return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(3 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63061,7 +63317,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63073,7 +63329,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63082,7 +63338,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63096,12 +63352,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63114,8 +63370,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -63136,8 +63392,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -63146,8 +63402,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -63156,7 +63412,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -63165,15 +63421,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -63184,9 +63440,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63208,11 +63464,11 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -63232,7 +63488,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63241,14 +63497,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63258,11 +63514,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63272,13 +63528,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63287,7 +63543,7 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; @@ -63312,7 +63568,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -63332,7 +63588,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -63345,62 +63601,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -63410,11 +63666,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -63424,15 +63680,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -63453,35 +63709,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -63495,17 +63751,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -63514,7 +63770,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -63524,13 +63780,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -63547,11 +63803,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -63589,7 +63845,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -63599,35 +63855,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -63651,7 +63907,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -63669,7 +63925,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -63686,7 +63942,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -63696,7 +63952,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -63713,7 +63969,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -63733,8 +63989,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -63758,7 +64014,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -63824,18 +64080,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -63860,7 +64116,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -63942,7 +64198,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -63952,7 +64208,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -63977,17 +64233,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64009,7 +64265,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64021,8 +64277,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64038,16 +64294,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64059,10 +64315,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64074,7 +64330,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64093,27 +64349,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* TypeFlags.Nullable */) === (getFalsyFlags(targetType) & 98304 /* TypeFlags.Nullable */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -64136,14 +64392,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -64158,21 +64414,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -64198,19 +64454,19 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64219,83 +64475,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; } return false; @@ -64311,38 +64567,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getReducedType(type) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) @@ -64371,19 +64627,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -64421,10 +64677,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -64469,24 +64725,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -64515,7 +64771,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -64528,7 +64784,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -64580,7 +64836,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperType && target !== markerSubType) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -64602,7 +64858,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -64650,7 +64906,7 @@ var ts; } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -64664,7 +64920,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -64673,19 +64929,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -64694,73 +64950,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -64779,10 +65035,10 @@ var ts; // // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. - if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -64792,10 +65048,9 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { - var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -64804,20 +65059,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -64836,25 +65091,22 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -64869,7 +65121,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -64877,19 +65129,19 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_19 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { @@ -64944,7 +65196,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -64967,28 +65219,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -64996,16 +65248,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65013,13 +65265,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65027,7 +65279,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65036,19 +65288,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65056,50 +65308,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65110,54 +65362,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65171,28 +65423,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); } - if (saved & 16 /* ReportsUnreliable */) { + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65208,42 +65460,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65251,30 +65503,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -65283,14 +65535,14 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; @@ -65300,29 +65552,29 @@ var ts; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -65330,18 +65582,18 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { + if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -65355,10 +65607,10 @@ var ts; // needs to have its constraint hoisted into an intersection with said type parameter, this way // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65370,20 +65622,20 @@ var ts; // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -65392,34 +65644,34 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65432,8 +65684,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -65448,7 +65700,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -65456,18 +65708,18 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65485,14 +65737,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -65511,12 +65763,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -65524,22 +65776,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65559,7 +65811,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -65569,12 +65821,12 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -65585,8 +65837,8 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { resetErrorInfo(saveErrorInfo); return result; @@ -65594,37 +65846,37 @@ var ts; } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source); - if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) { + if (!constraint || (sourceFlags & 262144 /* TypeFlags.TypeParameter */ && constraint.flags & 1 /* TypeFlags.Any */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* TypeFlags.NonPrimitive */), 3 /* RecursionFlags.Both */)) { resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65633,7 +65885,7 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65641,44 +65893,44 @@ var ts; } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */ && source.symbol === target.symbol) { + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -65687,15 +65939,15 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65708,7 +65960,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65718,7 +65970,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65727,7 +65979,7 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -65736,22 +65988,22 @@ var ts; return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -65761,41 +66013,41 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -65812,9 +66064,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -65822,7 +66074,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -65832,7 +66084,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -65859,8 +66111,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -65892,14 +66144,14 @@ var ts; var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -65914,7 +66166,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -65926,8 +66178,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -65936,7 +66188,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -65957,7 +66209,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -65974,7 +66226,7 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { @@ -65984,20 +66236,20 @@ var ts; return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66024,40 +66276,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66067,7 +66319,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66075,10 +66327,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -66089,7 +66341,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -66100,7 +66352,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -66142,29 +66394,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -66175,38 +66427,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66214,12 +66466,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66229,14 +66481,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66245,18 +66497,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -66268,12 +66520,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66282,24 +66534,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66311,17 +66563,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -66330,18 +66582,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -66349,7 +66601,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66364,10 +66616,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -66393,18 +66645,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -66427,45 +66679,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66475,7 +66727,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66483,7 +66735,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -66500,14 +66752,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66518,46 +66770,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -66570,19 +66822,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -66591,7 +66843,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -66611,7 +66863,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -66646,12 +66898,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -66667,7 +66919,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -66683,14 +66935,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; var _loop_22 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -66701,22 +66953,22 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } @@ -66737,7 +66989,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -66748,34 +67000,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -66783,7 +67035,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -66819,12 +67071,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -66839,7 +67091,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } // Return the inherited type of the given property or undefined if property doesn't exist in a base class. function getTypeOfPropertyInBaseClass(property) { @@ -66857,13 +67109,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -66881,12 +67133,12 @@ var ts; function isDeeplyNestedType(type, stack, depth, maxDepth) { if (maxDepth === void 0) { maxDepth = 3; } if (depth >= maxDepth) { - var identity_1 = getRecursionIdentity(type); + var identity_2 = getRecursionIdentity(type); var count = 0; var lastTypeId = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (getRecursionIdentity(t) === identity_1) { + if (getRecursionIdentity(t) === identity_2) { // We only count occurrences with a higher type id than the previous occurrence, since higher // type ids are an indicator of newer instantiations caused by recursion. if (t.id >= lastTypeId) { @@ -66909,14 +67161,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -66926,49 +67178,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -66999,14 +67251,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67017,12 +67269,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67030,7 +67282,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67042,7 +67294,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67056,10 +67308,10 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -67090,20 +67342,23 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : - getUnionType(types, 2 /* Subtype */); + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* TypeFlags.Nullable */) : + getUnionType(types, 2 /* UnionReduction.Subtype */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; + } + function isArrayOrTupleType(type) { + return isArrayType(type) || isTupleType(type); } function isMutableArrayOrTuple(type) { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; @@ -67114,22 +67369,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -67144,7 +67399,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -67171,44 +67426,44 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getBaseTypeOfLiteralType) : type; } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67239,10 +67494,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -67263,7 +67518,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -67271,7 +67526,7 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; @@ -67289,31 +67544,31 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 : - type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 : - type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 : - type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 : - type.flags & 117724 /* PossiblyFalsy */; + return type.flags & 1048576 /* TypeFlags.Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value === "" ? 128 /* TypeFlags.StringLiteral */ : 0 : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? type.value === 0 ? 256 /* TypeFlags.NumberLiteral */ : 0 : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* TypeFlags.BigIntLiteral */ : 0 : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* TypeFlags.BooleanLiteral */ : 0 : + type.flags & 117724 /* TypeFlags.PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* TypeFlags.DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* TypeFlags.DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -67322,24 +67577,24 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' // that isn't eliminated by a NonNullable instantiation. - var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + var reducedType = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? @@ -67367,10 +67622,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -67393,23 +67648,23 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -67439,7 +67694,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -67450,7 +67705,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -67480,7 +67735,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -67492,7 +67747,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -67508,7 +67763,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -67527,36 +67782,36 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -67579,8 +67834,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -67593,7 +67848,7 @@ var ts; } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { @@ -67605,7 +67860,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -67624,17 +67879,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -67645,25 +67900,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -67672,10 +67927,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -67687,7 +67942,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -67790,9 +68045,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -67838,40 +68093,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? false : "quit"; })); } return false; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || - type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -67879,7 +68134,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -67907,7 +68162,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -67924,14 +68179,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -67966,7 +68221,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -67976,9 +68231,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -67996,7 +68251,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68007,7 +68262,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68029,12 +68284,12 @@ var ts; sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); } function isValidBigIntString(s) { - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - if (result === 40 /* MinusToken */) { + if (result === 40 /* SyntaxKind.MinusToken */) { result = scanner.scan(); } var flags = scanner.getTokenFlags(); @@ -68043,27 +68298,27 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */); } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || - target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + return !!(target.flags & 8 /* TypeFlags.Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* TypeFlags.BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -68073,7 +68328,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -68155,12 +68410,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -68182,7 +68437,7 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -68191,10 +68446,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68209,21 +68464,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -68231,10 +68486,10 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -68242,12 +68497,12 @@ var ts; // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* InferencePriority.ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -68272,7 +68527,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -68285,11 +68540,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -68297,45 +68552,45 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); contravariant = !contravariant; } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); var oldPriority = priority; - priority |= 4 /* SubstituteSource */; + priority |= 4 /* InferencePriority.SubstituteSource */; inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority priority = oldPriority; } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -68343,17 +68598,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -68366,7 +68621,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -68384,19 +68639,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -68404,7 +68659,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -68432,7 +68687,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -68441,7 +68696,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -68451,7 +68706,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -68465,7 +68720,7 @@ var ts; var typeVariable; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -68475,9 +68730,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -68493,11 +68748,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -68508,7 +68763,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -68542,17 +68797,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -68560,7 +68815,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -68572,17 +68827,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -68601,7 +68856,7 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); @@ -68609,7 +68864,7 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; @@ -68631,7 +68886,7 @@ var ts; } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -68646,7 +68901,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -68654,7 +68909,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); @@ -68669,21 +68924,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -68692,14 +68947,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -68719,8 +68974,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -68740,7 +68995,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -68748,9 +69003,9 @@ var ts; function inferFromSignature(source, target, skipParameters) { if (!skipParameters) { var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -68758,7 +69013,7 @@ var ts; } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -68766,9 +69021,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -68793,34 +69048,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -68837,8 +69092,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -68852,14 +69107,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -68880,7 +69135,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -68950,7 +69205,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -68962,7 +69217,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -68971,7 +69226,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -68979,22 +69234,22 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -69005,44 +69260,44 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -69063,15 +69318,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -69110,12 +69365,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -69145,7 +69400,7 @@ var ts; var map = new ts.Map(); var count = 0; var _loop_23 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -69181,15 +69436,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -69213,7 +69468,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -69230,7 +69485,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -69244,7 +69499,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69260,11 +69515,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { + if (assignedType.flags & 131072 /* TypeFlags.Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { + if (assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType)) { reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types } // Our crude heuristic produces an invalid result in some cases: see GH#26130. @@ -69287,93 +69542,93 @@ var ts; function getTypeFacts(type, ignoreObjects) { if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; - if (flags & 4 /* String */) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & 4 /* TypeFlags.String */) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & 128 /* StringLiteral */) { + if (flags & 128 /* TypeFlags.StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { if (ignoreObjects) { - return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection. + return 16768959 /* TypeFacts.AndFactsMask */; // This is the identity element for computing type facts of intersection. } - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 16318463 /* TypeFacts.EmptyObjectStrictFacts */ : 16777215 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { - return 9830144 /* UndefinedFacts */; + if (flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { + return 9830144 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 9363232 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 9363232 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 465829888 /* Instantiable */) { + if (flags & 465829888 /* TypeFlags.Instantiable */) { return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : - strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; + strictNullChecks ? 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */)); return getIntersectionTypeFacts(type, ignoreObjects); } - return 16777215 /* All */; + return 16777215 /* TypeFacts.All */; } function getIntersectionTypeFacts(type, ignoreObjects) { // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 16777215 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 16777215 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; var f = getTypeFacts(t, ignoreObjects); oredFacts |= f; andedFacts &= f; } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 16768959 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -69393,7 +69648,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -69404,18 +69659,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -69432,21 +69687,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -69454,7 +69709,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -69472,37 +69727,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -69510,13 +69765,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -69536,7 +69791,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -69549,13 +69804,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -69564,25 +69819,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -69590,45 +69845,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -69639,11 +69894,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -69655,13 +69910,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -69673,14 +69928,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -69695,10 +69950,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -69706,17 +69961,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { var t = types_18[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -69730,16 +69985,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -69748,11 +70003,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -69763,11 +70018,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -69782,16 +70037,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -69809,7 +70064,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -69823,10 +70078,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -69834,7 +70089,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -69844,10 +70099,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -69867,8 +70122,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -69876,7 +70131,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -69884,30 +70139,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -69915,7 +70170,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -69923,7 +70178,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -69934,7 +70189,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -69943,7 +70198,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -69951,24 +70206,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -69978,18 +70233,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -70015,8 +70270,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -70032,7 +70287,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -70041,7 +70296,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -70054,56 +70309,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -70127,7 +70382,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -70139,7 +70394,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -70150,7 +70405,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -70167,14 +70422,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -70182,14 +70437,14 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -70199,15 +70454,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : - predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -70216,15 +70471,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -70233,7 +70488,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -70247,7 +70502,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -70257,7 +70512,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -70272,16 +70527,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -70298,7 +70553,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -70342,7 +70597,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -70368,7 +70623,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -70421,7 +70676,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -70436,7 +70691,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -70482,8 +70737,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -70499,8 +70754,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -70508,16 +70763,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -70526,7 +70781,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -70537,52 +70792,52 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType : - getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return type.flags & 2 /* TypeFlags.Unknown */ && assumeTrue ? nonNullUnknownType : + getTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -70614,35 +70869,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -70675,48 +70930,48 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) { + if (assumeTrue && (type.flags & 2 /* TypeFlags.Unknown */) && (operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */) && (valueType.flags & 65536 /* TypeFlags.Null */)) { return getUnionType([nullType, undefinedType]); } - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; - return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; + return type.flags & 2 /* TypeFlags.Unknown */ && facts & (1048576 /* TypeFacts.NENull */ | 2097152 /* TypeFacts.NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -70728,34 +70983,34 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } - if (type.flags & 1 /* Any */ && literal.text === "function") { + if (type.flags & 1 /* TypeFlags.Any */ && literal.text === "function") { return type; } - if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { + if (assumeTrue && type.flags & 2 /* TypeFlags.Unknown */ && literal.text === "object") { // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null // unknown type, and then narrows that to the non-primitive type. return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeFacts.TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */; var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text); return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -70768,16 +71023,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -70790,20 +71045,20 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { switch (text) { case "function": - return type.flags & 1 /* Any */ ? type : globalFunctionType; + return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType; case "object": - return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; default: return typeofTypesByName.get(text); } @@ -70822,7 +71077,7 @@ var ts; if (isTypeSubtypeOf(candidate, type)) { return candidate; } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(candidate, constraint)) { return getIntersectionType([type, candidate]); @@ -70897,7 +71152,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -70927,8 +71182,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -70939,7 +71194,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -70962,13 +71217,13 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; @@ -70981,9 +71236,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { + if (!(assignableType.flags & 131072 /* TypeFlags.Never */)) { return assignableType; } } @@ -71001,7 +71256,7 @@ var ts; if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71011,7 +71266,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71026,8 +71281,8 @@ var ts; return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { @@ -71042,11 +71297,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -71062,20 +71317,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -71084,11 +71339,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -71099,7 +71354,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -71123,9 +71378,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -71135,8 +71390,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -71145,11 +71400,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -71162,18 +71417,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 32768 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -71185,17 +71440,17 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -71204,8 +71459,8 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) : getContextualType(node)); return contextualType && !isGenericType(contextualType); } @@ -71217,10 +71472,10 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); - return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (n) { @@ -71238,9 +71493,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -71283,16 +71538,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { - var links = getNodeLinks(location); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { + var links = getNodeLinks(parent); + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -71326,7 +71581,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -71357,15 +71612,15 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } // We should only mark aliases as referenced if there isn't a local value declaration @@ -71379,32 +71634,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -71416,19 +71671,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -71437,11 +71692,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -71458,17 +71713,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -71476,11 +71731,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -71497,7 +71752,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -71514,11 +71769,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -71533,12 +71788,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -71548,22 +71803,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -71573,7 +71828,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -71581,9 +71836,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -71593,13 +71848,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -71641,36 +71896,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -71705,7 +71960,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -71753,9 +72008,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -71763,31 +72018,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -71799,17 +72054,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -71819,18 +72074,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -71841,14 +72096,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -71856,26 +72111,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -71937,12 +72192,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -71951,8 +72206,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -71972,12 +72227,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -71987,7 +72242,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -71995,23 +72250,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72019,22 +72274,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -72061,7 +72316,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -72075,7 +72330,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -72103,7 +72358,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -72128,11 +72383,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -72143,10 +72398,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -72179,7 +72434,7 @@ var ts; if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } @@ -72191,8 +72446,8 @@ var ts; var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var use = functionFlags & 2 /* FunctionFlags.Async */ ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); if (!iterationTypes) { return undefined; @@ -72200,7 +72455,7 @@ var ts; contextualReturnType = iterationTypes.returnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72226,7 +72481,7 @@ var ts; if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); } } return undefined; @@ -72245,7 +72500,7 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); var contextualReturnType = getContextualReturnType(functionDecl); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) @@ -72292,11 +72547,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -72305,13 +72560,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -72320,8 +72575,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -72354,8 +72609,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -72365,11 +72620,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (decl.initializer && getTypeOfExpression(binaryExpression.left)); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -72390,7 +72645,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -72404,18 +72659,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -72423,14 +72678,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -72454,7 +72709,7 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { @@ -72467,7 +72722,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -72488,7 +72743,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72523,7 +72778,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -72578,29 +72833,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -72609,24 +72864,24 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. - if (contextFlags && contextFlags & 1 /* Signature */) { + if (contextFlags && contextFlags & 1 /* ContextFlags.Signature */) { return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); } // For other purposes (e.g. determining whether to produce literal types) we only @@ -72635,7 +72890,7 @@ var ts; // literals actually end up widening to 'boolean' (see #48363). if (inferenceContext.returnMapper) { var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -72647,13 +72902,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -72676,7 +72931,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72685,60 +72940,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -72751,7 +73006,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -72760,7 +73015,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -72805,7 +73060,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -72820,7 +73075,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -72921,12 +73176,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -72948,18 +73203,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -72989,16 +73244,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -73027,18 +73282,18 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -73051,14 +73306,14 @@ var ts; var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -73074,27 +73329,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -73108,28 +73363,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -73138,14 +73393,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -73156,17 +73411,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -73182,7 +73437,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -73194,11 +73449,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -73218,9 +73473,9 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -73242,16 +73497,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -73263,29 +73518,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -73300,17 +73555,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -73344,10 +73599,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -73372,11 +73627,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -73408,12 +73663,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -73423,8 +73678,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -73470,7 +73725,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -73494,15 +73749,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -73517,7 +73772,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -73533,6 +73788,7 @@ var ts; } } else { + error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -73543,7 +73799,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -73557,7 +73813,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -73585,7 +73841,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -73595,12 +73851,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -73612,7 +73868,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -73632,7 +73888,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -73651,13 +73907,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -73706,10 +73962,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -73722,7 +73978,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -73737,7 +73993,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -73761,7 +74017,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -73775,10 +74031,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -73791,12 +74047,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -73824,13 +74080,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -73861,10 +74117,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -73898,7 +74154,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -73916,20 +74172,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -73938,7 +74194,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -73963,7 +74219,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -73975,7 +74231,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -73986,10 +74242,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -74012,13 +74268,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -74032,9 +74288,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -74057,7 +74313,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -74065,7 +74321,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -74077,7 +74333,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -74088,12 +74344,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -74120,7 +74376,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -74128,10 +74384,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -74146,10 +74402,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -74159,39 +74415,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */; if (kind) { reportError(node, kind); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -74200,13 +74456,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -74219,7 +74475,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -74243,7 +74499,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -74315,16 +74571,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -74346,8 +74602,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -74363,15 +74619,20 @@ var ts; prop = getPropertyOfType(apparentType, right.escapedText); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined + // here even if `Foo` is not a const enum. + // // The exceptions are: // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. - if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -74379,7 +74640,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -74399,7 +74660,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -74411,7 +74672,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -74430,11 +74691,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -74444,12 +74705,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -74462,12 +74723,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -74480,7 +74741,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; @@ -74498,13 +74759,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -74515,25 +74776,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -74545,7 +74806,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -74570,7 +74831,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -74658,7 +74919,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -74669,7 +74930,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -74677,7 +74938,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -74696,7 +74957,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -74712,7 +74973,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -74743,7 +75004,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -74771,7 +75032,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -74781,16 +75042,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -74800,19 +75061,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -74827,7 +75088,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -74867,13 +75128,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -74890,13 +75151,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -74910,7 +75171,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -74919,7 +75180,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -74931,8 +75192,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -74945,13 +75206,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -75015,16 +75276,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -75032,9 +75293,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -75045,11 +75306,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -75063,7 +75324,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -75087,7 +75348,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -75103,20 +75364,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -75125,12 +75386,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -75138,7 +75399,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -75166,8 +75427,8 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { - var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); + if (node.kind !== 165 /* SyntaxKind.Decorator */) { + var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { @@ -75175,7 +75436,7 @@ var ts; // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. var outerContext = getInferenceContext(node); - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -75189,7 +75450,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of // the source type uses the outer context's return mapper (which excludes inferences made from @@ -75203,7 +75464,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -75216,7 +75477,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -75231,10 +75492,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -75242,7 +75503,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -75252,24 +75513,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -75299,16 +75560,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -75333,7 +75594,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -75341,12 +75602,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -75356,7 +75617,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -75413,7 +75674,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -75431,13 +75692,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -75476,8 +75737,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -75495,17 +75756,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -75519,12 +75780,12 @@ var ts; var _loop_24 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -75546,30 +75807,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -75583,17 +75844,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -75627,7 +75888,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -75669,8 +75930,14 @@ var ts; var parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && ts.isInJSFile(node)) { + return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + var error = hasRestParameter + ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : ts.Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { // between min and max, but with no matching overload @@ -75729,15 +75996,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -75764,7 +76031,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -75792,7 +76060,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -75825,7 +76093,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -75848,7 +76116,7 @@ var ts; var i_1 = 0; var _loop_25 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -75933,7 +76201,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -75956,9 +76224,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -75980,7 +76248,7 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = 0 /* Normal */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -76033,14 +76301,14 @@ var ts; _loop_26(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -76053,7 +76321,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -76090,8 +76358,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -76111,7 +76379,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -76126,7 +76394,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -76135,13 +76403,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -76156,8 +76424,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -76184,7 +76452,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -76200,7 +76468,7 @@ var ts; // use the resolvingSignature singleton to indicate that we deferred processing. This result will be // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -76221,11 +76489,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -76258,7 +76526,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -76267,24 +76535,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -76295,14 +76563,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -76310,7 +76578,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -76318,7 +76586,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -76341,9 +76609,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -76351,16 +76619,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -76369,10 +76637,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { @@ -76422,7 +76690,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -76466,8 +76734,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76477,26 +76745,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -76511,8 +76779,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76523,38 +76791,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -76575,7 +76843,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -76591,16 +76859,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -76623,7 +76891,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -76664,7 +76932,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -76700,16 +76968,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -76732,10 +77000,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -76755,15 +77023,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -76780,11 +77048,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -76797,14 +77065,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -76813,20 +77081,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -76848,7 +77116,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -76863,13 +77131,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -76885,11 +77153,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + newSymbol.aliasTarget = resolveSymbol(symbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -76912,7 +77180,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -76932,40 +77200,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -76973,31 +77241,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -77028,12 +77296,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -77058,7 +77326,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -77066,12 +77334,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -77080,10 +77348,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -77099,19 +77367,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -77124,7 +77392,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -77134,16 +77402,16 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -77176,7 +77444,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77208,7 +77476,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77258,11 +77526,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -77286,14 +77554,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -77301,7 +77569,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -77311,7 +77579,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -77341,7 +77609,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -77361,7 +77629,7 @@ var ts; } } var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { // The contextual signature has a generic rest parameter. We first instantiate the contextual // signature (without fixing type parameters) and assign types to contextually typed parameters. var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); @@ -77405,7 +77673,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -77425,7 +77693,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -77444,7 +77712,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -77492,8 +77760,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -77505,14 +77773,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -77527,36 +77795,36 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { @@ -77565,9 +77833,9 @@ var ts; contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -77581,7 +77849,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -77624,13 +77892,13 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { @@ -77644,7 +77912,7 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -77656,14 +77924,14 @@ var ts; * whether the active clause contains a default clause. */ function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; // When in the default we only collect inequality facts // because default is 'in theory' a set of infinite // equalities. if (hasDefault) { // Value is not equal to any types after the active clause. for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -77673,7 +77941,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -77681,7 +77949,7 @@ var ts; else { // Add equalities for all types in the active clause. for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeFacts.TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -77696,17 +77964,17 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); var type_6 = getBaseConstraintOfType(operandType) || operandType; // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types. - if (type_6.flags & 3 /* AnyOrUnknown */) { - return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */; + if (type_6.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_1) === 556800 /* TypeFacts.AllTypeofNE */; } - return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* TypeFlags.Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -77730,15 +77998,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -77759,11 +78027,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -77784,17 +78052,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -77823,13 +78091,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -77840,9 +78108,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -77850,7 +78118,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -77859,21 +78127,21 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); } var instantiatedContextualSignature = inferenceContext ? @@ -77896,7 +78164,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -77909,7 +78177,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -77921,7 +78189,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -77979,27 +78247,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -78020,11 +78288,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -78032,12 +78300,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -78066,8 +78334,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -78085,21 +78353,36 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = void 0; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -78109,7 +78392,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -78125,7 +78408,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -78136,16 +78419,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -78153,28 +78436,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -78197,8 +78480,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -78218,7 +78501,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var t = types_21[_i]; @@ -78233,30 +78516,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -78268,7 +78551,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -78282,8 +78565,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -78296,8 +78579,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -78322,9 +78605,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -78344,7 +78627,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -78355,17 +78638,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -78387,18 +78670,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -78407,15 +78690,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -78426,7 +78709,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -78442,14 +78725,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* TypeFlags.Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -78458,31 +78741,31 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -78497,59 +78780,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -78580,9 +78863,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -78599,8 +78882,8 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var parent = ts.walkUpParenthesizedExpressions(node.parent); checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } @@ -78660,11 +78943,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -78673,11 +78956,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -78689,28 +78972,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -78719,8 +79002,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -78731,21 +79014,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -78761,26 +79044,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -78798,21 +79081,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -78821,56 +79104,56 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -78880,7 +79163,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -78898,16 +79181,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -78917,12 +79200,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -78932,15 +79215,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -78959,7 +79242,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -78973,13 +79256,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -79022,12 +79305,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -79053,20 +79336,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -79083,15 +79366,15 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { @@ -79105,7 +79388,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -79118,7 +79401,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -79131,7 +79414,7 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); @@ -79140,11 +79423,11 @@ var ts; return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -79156,7 +79439,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -79165,7 +79448,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -79178,7 +79461,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -79198,17 +79481,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -79218,9 +79501,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -79229,7 +79512,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -79244,28 +79527,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -79286,7 +79569,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -79297,23 +79580,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -79361,11 +79644,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -79395,7 +79678,7 @@ var ts; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -79420,7 +79703,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -79453,7 +79736,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -79465,7 +79748,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -79480,7 +79763,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -79490,8 +79773,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -79511,7 +79794,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -79522,7 +79805,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -79540,18 +79823,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -79569,113 +79852,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -79700,19 +79983,28 @@ var ts; if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) { + checkNodeDeferred(node); + addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); + } + function checkTypeParameterDeferred(node) { + if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) { + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); var modifiers = getVarianceModifiers(typeParameter); - if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + if (modifiers) { var symbol = getSymbolOfNode(node.parent); - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); - var saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { + error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubType : markerSuperType); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperType : markerSubType); + var saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); } function checkParameter(node) { // Grammar checking @@ -79722,11 +80014,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -79737,13 +80029,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -79767,7 +80059,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -79801,13 +80093,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -79821,11 +80113,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -79834,29 +80126,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -79872,17 +80164,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -79894,18 +80186,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -79917,11 +80209,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -79932,24 +80224,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -79959,19 +80251,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -80020,15 +80312,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -80045,7 +80337,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -80093,7 +80385,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -80110,7 +80402,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -80120,9 +80412,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -80130,8 +80422,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -80163,7 +80455,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -80184,9 +80476,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -80202,7 +80494,7 @@ var ts; superCallStatement = statement; break; } - if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -80225,7 +80517,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -80243,9 +80535,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -80253,25 +80545,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -80283,7 +80575,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -80315,15 +80607,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -80339,10 +80631,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -80381,29 +80673,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -80423,15 +80715,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -80439,14 +80731,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -80495,7 +80787,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -80505,7 +80797,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -80532,8 +80824,8 @@ var ts; if (node.assertions) { var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -80543,31 +80835,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -80592,16 +80884,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -80618,8 +80910,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -80628,7 +80920,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -80657,7 +80949,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -80682,7 +80974,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -80698,8 +80990,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -80710,10 +81002,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -80757,13 +81049,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -80773,7 +81065,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -80813,15 +81105,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -80854,56 +81146,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -80939,32 +81231,32 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -80984,16 +81276,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -81003,7 +81295,7 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } @@ -81027,7 +81319,7 @@ var ts; var baseConstraint = getBaseConstraintOfType(type); // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { + if (!baseConstraint || (baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { // Nothing to do if `Awaited` doesn't exist var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); if (awaitedSymbol) { @@ -81073,7 +81365,7 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); } @@ -81190,7 +81482,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -81213,10 +81505,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -81236,7 +81528,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -81249,26 +81541,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -81290,9 +81582,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -81327,15 +81619,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -81344,13 +81636,13 @@ var ts; var commonEntityName; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -81395,15 +81687,15 @@ var ts; error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } var firstDecorator = node.decorators[0]; - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -81412,23 +81704,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -81518,9 +81810,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -81534,7 +81826,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -81550,7 +81842,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -81560,7 +81852,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -81578,7 +81870,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -81606,42 +81898,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -81652,41 +81944,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -81697,7 +81989,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -81714,7 +82006,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -81726,17 +82018,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -81773,7 +82065,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -81804,7 +82096,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -81820,10 +82112,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -81836,9 +82128,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -81857,38 +82149,38 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -81905,7 +82197,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -81923,17 +82215,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -81953,8 +82245,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -81968,8 +82260,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -81983,53 +82275,53 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -82040,7 +82332,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -82048,13 +82340,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -82072,7 +82364,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -82104,35 +82396,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -82163,23 +82455,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } if (ts.isBindingElement(node)) { - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -82189,15 +82481,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -82208,7 +82500,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -82225,7 +82517,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -82236,7 +82528,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -82250,7 +82542,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -82266,7 +82558,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (node.initializer) { @@ -82276,10 +82568,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -82287,7 +82579,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -82297,24 +82589,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -82340,7 +82632,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -82349,13 +82641,13 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) @@ -82369,7 +82661,7 @@ var ts; // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -82409,7 +82701,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -82433,7 +82725,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -82463,7 +82755,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -82474,12 +82766,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -82504,29 +82796,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -82558,7 +82850,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -82572,7 +82864,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -82585,7 +82877,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -82602,7 +82894,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -82617,14 +82909,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -82633,10 +82925,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -82653,22 +82945,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -82676,7 +82968,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -82688,7 +82980,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -82697,12 +82989,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -82710,9 +83002,9 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { - return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; @@ -82759,9 +83051,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -82831,17 +83123,17 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } return undefined; } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; @@ -82851,7 +83143,7 @@ var ts; var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; @@ -82890,20 +83182,20 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? + return use & 8 /* IterationUse.ForOfFlag */ ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { // for a sync iterable in an async context, only use the cached types if they are valid. if (iterationTypes !== noIterationTypes) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); @@ -82914,16 +83206,16 @@ var ts; } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : noIterationTypes); @@ -82989,7 +83281,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -83004,11 +83296,11 @@ var ts; function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } @@ -83088,13 +83380,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -83149,15 +83441,15 @@ var ts; if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" @@ -83263,7 +83555,7 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); @@ -83275,15 +83567,15 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync) || errorType : isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -83303,21 +83595,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -83328,7 +83620,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -83336,7 +83628,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -83357,7 +83649,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -83366,7 +83658,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -83403,7 +83695,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -83435,8 +83727,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -83448,7 +83740,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -83468,8 +83760,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -83498,9 +83790,9 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; var _loop_28 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared @@ -83520,7 +83812,7 @@ var ts; function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; var _loop_29 = function (info) { if (info === checkInfo) @@ -83561,7 +83853,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -83640,9 +83932,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -83729,7 +84021,7 @@ var ts; if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -83750,15 +84042,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -83790,18 +84082,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -83836,7 +84128,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -83886,7 +84178,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -83900,7 +84192,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -83919,12 +84211,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -83937,13 +84229,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -83954,9 +84246,9 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible @@ -83988,10 +84280,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -84007,7 +84299,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -84019,7 +84311,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -84027,11 +84319,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -84054,7 +84346,7 @@ var ts; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -84073,7 +84365,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -84087,7 +84379,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -84098,24 +84390,24 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { // either base or derived property is private - not override, skip it continue; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */ + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment continue; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -84123,12 +84415,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -84145,16 +84437,16 @@ var ts; continue; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { // method is overridden with method or property -- correct case continue; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -84220,20 +84512,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -84243,7 +84535,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -84258,7 +84550,7 @@ var ts; ts.setParent(reference, staticBlock); reference.flowNode = staticBlock.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) { + if (!(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */)) { return true; } } @@ -84273,7 +84565,7 @@ var ts; ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 32768 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -84286,7 +84578,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -84319,7 +84611,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -84331,8 +84623,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -84357,7 +84649,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -84374,7 +84666,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -84382,20 +84674,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -84405,60 +84697,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -84494,9 +84786,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -84530,7 +84822,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -84559,9 +84851,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -84592,7 +84884,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -84605,7 +84897,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -84615,7 +84907,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -84631,10 +84923,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -84644,7 +84936,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -84676,23 +84968,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -84703,12 +84995,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -84718,7 +85010,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -84729,20 +85021,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -84756,9 +85048,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -84799,39 +85091,39 @@ var ts; // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -84856,15 +85148,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -84890,11 +85182,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -84903,8 +85195,11 @@ var ts; var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration); var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!ts.isNightly()) { + grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -84937,11 +85232,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -84963,20 +85258,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -84985,7 +85280,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -85000,8 +85295,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -85009,10 +85304,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -85032,12 +85327,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -85047,7 +85342,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -85057,7 +85352,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -85105,15 +85400,15 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -85123,7 +85418,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -85135,8 +85430,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -85153,14 +85448,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -85176,10 +85471,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -85214,11 +85509,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -85264,177 +85559,177 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -85515,7 +85810,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -85527,38 +85822,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 163 /* SyntaxKind.TypeParameter */: + checkTypeParameterDeferred(node); + break; + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -85566,7 +85864,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -85578,9 +85876,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -85592,7 +85890,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -85612,13 +85910,13 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -85642,7 +85940,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -85712,14 +86010,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -85727,17 +86025,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -85745,17 +86043,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -85799,7 +86097,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -85807,25 +86105,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -85833,16 +86131,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -85870,13 +86168,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -85887,12 +86185,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -85902,7 +86200,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -85912,7 +86210,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -85922,17 +86220,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -85948,28 +86246,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -85980,13 +86278,13 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name)); if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { @@ -85998,16 +86296,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -86019,12 +86317,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -86039,7 +86337,7 @@ var ts; function resolveJSDocMemberName(name, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -86051,18 +86349,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -86076,12 +86374,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -86089,27 +86387,32 @@ var ts; return propertyDeclaration; } } - else if (ts.isMetaProperty(parent)) { - var parentType = getTypeOfNode(parent); - var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === 103 /* NewKeyword */) { + else if (ts.isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { + // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } + // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but + // we have a fake expression type made for other reasons already, whose transient `meta` + // member should more exactly be the kind of (declarationless) symbol we want. + // (See #44364 and #45031 for relevant implementation PRs) + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { + return getGlobalImportMetaExpressionType().members.get("meta"); + } + // no other meta properties are valid syntax, thus no others should have symbols + return undefined; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -86121,25 +86424,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -86148,7 +86451,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -86156,19 +86459,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -86178,14 +86481,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -86194,17 +86497,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -86235,7 +86538,7 @@ var ts; if (ts.isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { var symbol = getSymbolAtLocation(node); @@ -86245,7 +86548,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -86266,23 +86569,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -86292,7 +86595,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -86325,14 +86628,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -86342,8 +86645,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -86362,18 +86665,18 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] - : ts.singleElementArray(tryGetAliasTarget(symbol)); + : ts.singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol) { + function tryGetTarget(symbol) { var target; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -86412,13 +86715,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -86436,19 +86739,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -86471,7 +86774,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -86480,20 +86783,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -86509,9 +86812,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -86552,20 +86855,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -86573,7 +86876,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -86590,7 +86893,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -86603,9 +86906,9 @@ var ts; if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } - var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -86643,18 +86946,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); - } - function isOptionalUninitializedParameter(parameter) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86662,10 +86960,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86688,19 +86986,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -86710,7 +87008,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -86726,14 +87024,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -86752,28 +87050,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -86789,37 +87087,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -86838,7 +87136,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -86859,7 +87157,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -86967,18 +87265,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -86994,7 +87292,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -87031,7 +87329,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -87042,9 +87340,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -87091,7 +87389,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -87119,12 +87417,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -87195,7 +87493,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -87257,28 +87555,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -87292,29 +87590,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -87333,14 +87631,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -87354,69 +87652,69 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -87428,186 +87726,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ && - node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -87625,41 +87922,41 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.fail(); } @@ -87670,10 +87967,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -87702,7 +87999,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -87727,7 +88024,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -87762,7 +88059,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -87798,7 +88095,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -87827,7 +88124,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -87844,6 +88141,9 @@ var ts; return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { + if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } function checkGrammarClassDeclarationHeritageClauses(node) { @@ -87852,7 +88152,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -87865,7 +88165,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -87881,14 +88181,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -87899,21 +88199,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -87931,7 +88231,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -87942,23 +88242,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */) { + if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -87973,25 +88273,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -88006,14 +88306,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -88033,7 +88333,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -88043,7 +88343,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -88078,16 +88378,32 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -88096,8 +88412,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -88108,12 +88424,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -88128,20 +88444,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -88151,22 +88467,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -88174,11 +88490,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -88200,17 +88516,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -88220,26 +88536,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -88247,9 +88563,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -88262,10 +88578,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -88283,7 +88599,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -88291,17 +88607,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -88312,11 +88628,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -88324,8 +88640,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -88340,13 +88656,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -88370,18 +88686,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -88389,7 +88705,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -88406,8 +88722,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -88419,7 +88735,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88428,7 +88744,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -88441,7 +88757,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -88458,8 +88774,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -88486,15 +88802,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -88512,12 +88828,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -88575,7 +88891,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -88585,11 +88901,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -88605,11 +88921,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88631,14 +88947,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -88646,7 +88962,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -88655,10 +88971,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -88669,7 +88985,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -88686,19 +89002,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -88711,7 +89027,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -88732,7 +89048,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -88766,7 +89082,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -88774,7 +89090,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -88782,10 +89098,10 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } var nodeArguments = node.arguments; if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) { @@ -88793,7 +89109,7 @@ var ts; checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { var assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } if (nodeArguments.length === 0 || nodeArguments.length > 2) { @@ -88809,14 +89125,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -88825,35 +89141,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -88865,9 +89181,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -88875,7 +89191,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -88897,14 +89213,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -88924,17 +89240,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -89048,7 +89364,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -89056,11 +89372,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -89107,8 +89423,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -89154,446 +89470,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -89818,7 +90134,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -89828,7 +90144,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -89971,14 +90287,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -90055,8 +90371,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -90106,19 +90422,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -90186,7 +90502,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -90279,12 +90595,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -90335,7 +90651,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -90348,13 +90664,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -90385,23 +90701,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90419,9 +90735,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90502,7 +90818,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -90517,27 +90833,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -90599,7 +90915,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -90884,9 +91200,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -90927,14 +91243,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -90949,10 +91265,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -91155,7 +91471,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -91211,8 +91527,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -91238,14 +91554,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -91296,17 +91612,17 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -91317,7 +91633,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -91340,7 +91656,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -91360,10 +91676,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -91376,7 +91692,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -91384,13 +91700,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -91410,15 +91726,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -91438,30 +91754,30 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -91472,80 +91788,80 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. // falls through - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.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 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91555,7 +91871,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91565,35 +91881,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -91603,40 +91919,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -91650,28 +91966,28 @@ var ts; return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -91680,16 +91996,16 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return ts.visitEachChild(node, visitor, context); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); - var classStatement = facts & 2 /* HasConstructorDecorators */ + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var classStatement = facts & 2 /* ClassFacts.HasConstructorDecorators */ ? createClassDeclarationHeadWithDecorators(node, name) : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; @@ -91697,7 +92013,7 @@ var ts; addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -91709,20 +92025,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -91738,21 +92054,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -91768,7 +92084,7 @@ var ts; // ${members} // } // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : undefined; var classDeclaration = factory.createClassDeclaration( @@ -91777,8 +92093,8 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); @@ -91879,7 +92195,7 @@ var ts; var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -91897,7 +92213,7 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); @@ -92030,12 +92346,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92186,9 +92502,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -92198,7 +92514,7 @@ var ts; : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); ts.setTextRange(helper, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); return helper; } /** @@ -92226,12 +92542,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); return expression; } @@ -92257,7 +92573,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -92294,13 +92610,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); @@ -92316,10 +92632,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -92329,7 +92645,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -92340,12 +92656,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -92362,15 +92678,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -92407,7 +92723,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -92452,83 +92768,83 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return factory.createVoidZero(); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return serializeTypeNode(node.type); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return factory.createIdentifier("Array"); - case 177 /* TypePredicate */: - case 133 /* BooleanKeyword */: + case 177 /* SyntaxKind.TypePredicate */: + case 133 /* SyntaxKind.BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: switch (node.literal.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: - case 8 /* NumericLiteral */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 8 /* SyntaxKind.NumericLiteral */: return factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 151 /* SymbolKeyword */: - return languageVersion < 2 /* ES2015 */ + case 151 /* SyntaxKind.SymbolKeyword */: + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return serializeTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -92541,13 +92857,13 @@ var ts; var serializedUnion; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -92607,7 +92923,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES2015 */ + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -92629,12 +92945,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -92650,14 +92966,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -92685,7 +93001,7 @@ var ts; * available. */ function getGlobalBigIntNameWithFallback() { - return languageVersion < 99 /* ESNext */ + return languageVersion < 99 /* ScriptTarget.ESNext */ ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), /*questionToken*/ undefined, factory.createIdentifier("BigInt"), /*colonToken*/ undefined, factory.createIdentifier("Object")) @@ -92748,7 +93064,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -92776,7 +93092,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { return undefined; } var updated = factory.updatePropertyDeclaration(node, @@ -92807,11 +93123,11 @@ var ts; } var statements = []; resumeLexicalEnvironment(); - var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); + var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); } // Transform parameters into property assignments. Transforms this: // @@ -92830,12 +93146,12 @@ var ts; if (superStatementIndex >= 0) { ts.addRange(statements, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor + // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = ts.addRange(parameterPropertyAssignments, statements); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - // Add remaining statements from the body, skipping the super() call if it was found - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1)); + // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -92855,10 +93171,10 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node) { @@ -92885,7 +93201,7 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { @@ -92961,7 +93277,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -92981,7 +93297,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -92999,7 +93315,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93076,7 +93392,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93084,7 +93400,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93092,7 +93408,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93158,7 +93474,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93246,12 +93562,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93276,7 +93592,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93286,7 +93602,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93307,7 +93623,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93315,7 +93631,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93323,7 +93639,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93376,7 +93692,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93423,13 +93739,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93452,8 +93768,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*decorators*/ undefined, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) @@ -93477,14 +93793,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93525,8 +93841,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93586,7 +93902,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -93599,7 +93915,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -93620,7 +93936,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -93628,7 +93944,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -93637,7 +93953,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -93646,7 +93962,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Creates a statement for the provided expression. This is used in calls to `map`. @@ -93691,7 +94007,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -93708,37 +94024,37 @@ var ts; : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* TypeScriptSubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -93753,11 +94069,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -93771,7 +94087,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -93780,7 +94096,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -93797,11 +94113,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -93812,8 +94128,8 @@ var ts; || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -93839,9 +94155,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -93867,7 +94183,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -93930,13 +94246,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -93962,7 +94278,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -93970,50 +94286,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 8388608 /* ContainsClassFields */) { + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 8388608 /* ContainsClassFields */ || - node.transformFlags & 33554432 /* ContainsLexicalSuper */ && + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94032,17 +94348,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94072,7 +94388,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94088,19 +94404,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94149,10 +94465,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94214,11 +94530,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94237,7 +94553,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94256,7 +94572,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94270,7 +94586,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var info = void 0; if (info = accessPrivateIdentifier(node.operand.name)) { @@ -94279,7 +94595,7 @@ var ts; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94302,7 +94618,7 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { var operand = visitInvalidSuperProperty(node.operand); return ts.isPrefixUnaryExpression(node) ? factory.updatePrefixUnaryExpression(node, operand) : @@ -94418,7 +94734,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94445,7 +94761,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94487,7 +94803,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94502,12 +94818,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94547,28 +94863,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94576,8 +94892,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94590,19 +94906,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -94631,7 +94947,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94641,19 +94957,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -94682,12 +94998,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -94742,13 +95058,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -94781,7 +95097,7 @@ var ts; } resumeLexicalEnvironment(); var needsSyntheticConstructor = !constructor && isDerivedClass; - var indexOfFirstStatementAfterSuper = 0; + var indexOfFirstStatementAfterSuperAndPrologue = 0; var prologueStatementCount = 0; var superStatementIndex = -1; var statements = []; @@ -94790,8 +95106,11 @@ var ts; superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; } } if (needsSyntheticConstructor) { @@ -94827,22 +95146,20 @@ var ts; } } if (parameterPropertyDeclarationCount > 0) { - var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); // If there was a super() call found, add parameter properties immediately after it if (superStatementIndex >= 0) { ts.addRange(statements, parameterProperties); } - // If a synthetic super() call was added, add them just after it - else if (needsSyntheticConstructor) { - statements = __spreadArray(__spreadArray([ - statements[0] - ], parameterProperties, true), statements.slice(1), true); - } - // Since there wasn't a super() call, add them to the top of the constructor else { - statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true); + // Add add parameter properties to the top of the constructor after the prologue + var superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) + superAndPrologueStatementCount++; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true); } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -94852,7 +95169,7 @@ var ts; addPropertyOrClassStaticBlockStatements(statements, properties, receiver); // Add existing statements after the initial prologues and super call if (constructor) { - ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), @@ -94937,7 +95254,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -94956,7 +95273,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -94976,7 +95293,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -94995,32 +95312,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95059,13 +95376,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95075,10 +95392,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95088,7 +95405,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95109,24 +95426,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95139,8 +95456,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95173,7 +95490,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95193,7 +95510,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95226,7 +95543,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95236,7 +95553,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95245,12 +95562,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95261,12 +95578,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95282,7 +95599,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95294,7 +95611,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95305,12 +95622,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95321,12 +95638,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95343,9 +95660,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95387,9 +95704,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95403,7 +95720,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95443,7 +95760,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95562,8 +95879,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -95575,10 +95892,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -95594,39 +95911,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -95634,27 +95951,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -95737,7 +96054,7 @@ var ts; /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95753,7 +96070,7 @@ var ts; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95768,7 +96085,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95783,7 +96100,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95804,7 +96121,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -95858,9 +96175,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -95886,7 +96203,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -95899,10 +96216,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -95946,21 +96263,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -95973,8 +96290,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96001,30 +96318,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96044,19 +96361,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -96066,7 +96383,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -96076,7 +96393,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -96091,20 +96408,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -96174,7 +96491,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -96206,7 +96523,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -96228,88 +96545,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -96323,15 +96640,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -96343,7 +96660,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -96352,7 +96669,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -96363,7 +96680,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -96386,7 +96703,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -96413,9 +96730,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -96436,10 +96753,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -96467,10 +96784,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -96482,7 +96799,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -96508,8 +96825,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -96526,8 +96843,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -96555,7 +96872,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -96575,10 +96892,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -96597,18 +96914,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -96616,15 +96933,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -96640,7 +96957,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -96658,7 +96975,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -96704,13 +97021,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateMethodDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96723,13 +97040,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateFunctionDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96753,13 +97070,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96776,13 +97093,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -96793,10 +97110,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -96835,11 +97152,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96848,7 +97165,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96864,32 +97181,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96897,21 +97214,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -96924,8 +97241,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96952,30 +97269,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96995,14 +97312,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -97027,11 +97344,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -97059,29 +97376,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97123,7 +97440,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -97146,10 +97463,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -97158,7 +97475,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -97168,8 +97485,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -97179,17 +97496,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -97206,7 +97523,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -97240,11 +97557,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -97294,7 +97611,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -97318,12 +97635,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -97349,7 +97666,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -97371,7 +97688,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -97388,7 +97705,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -97404,7 +97721,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -97413,13 +97730,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97427,15 +97744,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -97504,7 +97821,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -97569,7 +97886,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -97609,14 +97926,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - else if (node.kind === 10 /* StringLiteral */) { + else if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 288 /* JsxExpression */) { + else if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -97710,7 +98027,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -98013,11 +98330,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98025,9 +98342,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98217,7 +98534,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -98227,7 +98544,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -98238,15 +98555,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -98261,11 +98578,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -98277,9 +98594,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -98287,115 +98604,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -98406,14 +98723,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -98421,17 +98738,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -98447,11 +98764,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -98478,30 +98795,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -98510,15 +98827,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -98551,18 +98868,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -98619,25 +98936,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -98655,19 +98972,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98693,7 +99010,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -98704,10 +99021,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -98741,7 +99058,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98756,7 +99073,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -98800,7 +99117,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -98810,7 +99127,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -98833,7 +99150,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -98872,7 +99189,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -98893,7 +99210,7 @@ var ts; // ``` insertCaptureThisForNodeIfNeeded(prologue, constructor); } - var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), + var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), /*location*/ constructor.body.statements), /*multiLine*/ true); ts.setTextRange(body, constructor.body); @@ -98922,11 +99239,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -98934,7 +99251,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -98943,10 +99260,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -99035,11 +99352,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -99057,11 +99374,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -99092,10 +99409,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -99105,7 +99422,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -99117,13 +99434,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -99136,7 +99453,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -99150,7 +99467,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -99158,38 +99475,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -99197,11 +99514,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -99220,21 +99537,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -99273,7 +99590,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -99281,7 +99598,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -99295,7 +99612,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -99311,20 +99628,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -99332,7 +99649,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -99355,12 +99672,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -99369,9 +99686,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -99381,17 +99698,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -99406,13 +99723,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, @@ -99430,14 +99747,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -99480,7 +99797,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -99499,7 +99816,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -99520,10 +99837,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -99533,11 +99850,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99568,9 +99885,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -99598,12 +99915,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -99612,10 +99929,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -99632,7 +99949,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99641,11 +99958,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -99654,7 +99971,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 262144 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -99720,18 +100037,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -99758,16 +100075,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -99787,50 +100104,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -99878,7 +100195,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -99910,18 +100227,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -99937,33 +100254,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -99978,9 +100295,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 524288 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 524288 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -99993,7 +100310,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -100005,7 +100322,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -100021,7 +100338,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -100032,7 +100349,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -100052,7 +100369,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -100096,11 +100413,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -100125,11 +100442,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -100138,7 +100455,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -100251,15 +100568,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -100285,12 +100602,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -100352,7 +100669,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -100361,17 +100678,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -100391,18 +100708,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -100415,7 +100732,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -100424,27 +100741,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -100452,7 +100769,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -100511,19 +100828,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -100545,20 +100862,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -100613,14 +100930,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -100629,7 +100946,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -100648,7 +100965,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -100661,17 +100978,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -100714,11 +101031,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -100791,7 +101108,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -100848,15 +101165,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -100870,7 +101187,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -100882,12 +101199,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -100976,13 +101293,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -100998,12 +101315,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -101011,7 +101328,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -101041,7 +101358,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -101076,15 +101393,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -101096,13 +101413,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -101112,9 +101429,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -101122,16 +101439,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -101142,7 +101459,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -101156,7 +101473,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -101172,10 +101489,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -101188,9 +101505,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -101201,7 +101518,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -101238,9 +101555,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -101257,19 +101574,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -101292,18 +101609,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -101322,9 +101639,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -101384,7 +101701,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -101564,11 +101881,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -101622,7 +101939,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -101645,7 +101962,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -101659,13 +101976,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -101678,30 +101995,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -101716,23 +102033,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -101745,9 +102062,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -101906,13 +102223,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101937,9 +102254,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -101955,7 +102272,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -101967,7 +102284,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -101999,7 +102316,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -102033,13 +102350,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -102056,12 +102373,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -102106,7 +102423,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -102172,7 +102489,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -102361,35 +102678,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -102819,7 +103136,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -102832,7 +103149,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -102964,7 +103281,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -102977,7 +103294,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -103008,7 +103325,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -103054,7 +103371,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -103068,7 +103385,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -103097,7 +103414,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -103107,7 +103424,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -103119,8 +103436,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -103133,7 +103450,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -103146,18 +103463,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -103167,24 +103484,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -103192,7 +103509,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -103202,7 +103519,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -103219,7 +103536,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -103231,7 +103548,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103245,7 +103562,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -103258,7 +103575,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -103268,7 +103585,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103277,7 +103594,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -103286,14 +103603,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -103305,8 +103622,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -103314,7 +103631,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -103322,7 +103639,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -103419,7 +103736,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -103431,7 +103748,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -103443,8 +103760,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -103457,7 +103774,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -103466,7 +103783,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -103480,7 +103797,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -103489,7 +103806,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -103500,7 +103817,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -103511,7 +103828,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -103520,7 +103837,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -103529,7 +103846,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -103538,7 +103855,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -103547,13 +103864,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -103597,7 +103914,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -103770,8 +104087,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -103781,18 +104098,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -103816,33 +104133,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -103892,8 +104209,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -103904,9 +104221,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -103917,9 +104234,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -103930,9 +104247,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -103943,8 +104260,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -103955,9 +104272,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -103965,7 +104282,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -103992,12 +104309,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -104013,7 +104330,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 4194304 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -104149,7 +104466,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -104234,7 +104551,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -104303,13 +104620,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -104325,23 +104642,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -104350,30 +104667,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4194304 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -104389,24 +104706,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -104432,7 +104749,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -104458,7 +104775,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -104501,7 +104818,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -104528,7 +104845,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -104564,7 +104881,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -104582,7 +104899,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -104603,7 +104920,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -104623,13 +104940,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -104638,7 +104955,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -104685,7 +105002,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -104699,7 +105016,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -104733,7 +105050,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -104743,11 +105060,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -104788,12 +105105,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -104844,7 +105161,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), @@ -104872,7 +105189,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); @@ -104899,7 +105216,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -104957,7 +105274,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -104972,7 +105289,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -104994,7 +105311,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -105006,7 +105323,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -105049,10 +105366,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -105135,8 +105452,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -105181,7 +105498,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -105194,7 +105511,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -105209,7 +105526,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -105221,7 +105538,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -105248,8 +105565,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -105265,7 +105582,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -105290,7 +105607,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -105325,13 +105642,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -105340,9 +105657,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105351,9 +105668,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105366,16 +105683,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -105464,11 +105781,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -105488,7 +105805,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -105535,7 +105852,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -105657,8 +105974,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 1048576 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -105692,7 +106009,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -105758,7 +106075,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -105782,19 +106099,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -105853,13 +106170,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -105935,7 +106252,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -105988,7 +106305,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -106038,9 +106355,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -106051,7 +106368,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -106103,9 +106420,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -106116,7 +106433,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106165,10 +106482,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -106262,8 +106579,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -106323,7 +106640,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106335,7 +106652,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -106348,43 +106665,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -106566,30 +106883,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 4194304 /* TransformFlags.ContainsDynamicImport */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -106639,7 +106956,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -106669,7 +106986,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -106685,7 +107002,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -106730,8 +107047,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106747,7 +107064,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -106782,10 +107099,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -106797,7 +107114,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -106832,11 +107149,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -106848,7 +107165,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -106926,7 +107243,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -106969,8 +107286,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -107009,14 +107326,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -107034,7 +107351,7 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause( @@ -107042,16 +107359,16 @@ var ts; /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -107072,12 +107389,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); @@ -107145,7 +107462,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -107154,7 +107471,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -107177,8 +107494,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -107225,7 +107542,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -107280,14 +107597,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107309,14 +107626,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -107340,7 +107657,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -107358,31 +107675,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107405,7 +107722,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -107422,14 +107739,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -107444,36 +107761,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -107485,9 +107802,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -107510,40 +107827,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -107554,61 +107871,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -107625,7 +107942,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -107674,7 +107991,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -107693,13 +108010,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -107758,7 +108075,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -107767,7 +108084,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -107803,7 +108120,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -107874,10 +108191,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -107900,14 +108217,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -108044,11 +108361,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -108056,7 +108373,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -108069,7 +108386,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = factory.updateParameterDeclaration(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -108086,7 +108403,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -108094,19 +108411,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -108114,12 +108431,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -108130,28 +108447,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -108178,7 +108495,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -108215,7 +108532,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -108241,7 +108558,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -108261,7 +108578,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -108279,34 +108596,44 @@ var ts; if (!decl.importClause) { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // The `importClause` visibility corresponds to the default's visibility. var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, - /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } // Named imports (optionally with visible default) var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Augmentation of export depends on import if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, - /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Nothing visible } + function getResolutionModeOverrideForClauseInNightly(assertClause) { + var mode = ts.getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!ts.isNightly()) { + context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } function transformAndReplaceLatePaintedStatements(statements) { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. @@ -108325,7 +108652,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -108383,10 +108710,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -108404,29 +108731,29 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -108436,48 +108763,48 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateSetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { + case 176 /* SyntaxKind.IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -108485,13 +108812,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -108503,22 +108830,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -108541,7 +108868,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -108551,7 +108878,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -108561,17 +108888,17 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -108579,7 +108906,9 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); + preserveJsDoc(statement, input); + ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -108590,22 +108919,26 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { + if (lateMarkedStatements) { + while (ts.orderedRemoveItem(lateMarkedStatements, input)) + ; + } if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -108626,14 +108959,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -108642,7 +108975,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -108661,10 +108994,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -108675,11 +109008,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, @@ -108700,17 +109033,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -108746,7 +109079,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -108756,10 +109089,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -108801,26 +109134,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -108831,10 +109164,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -108845,7 +109178,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -108853,7 +109186,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -108876,7 +109209,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -108924,12 +109257,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 125951 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 125951 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -108949,13 +109282,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -108965,22 +109298,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 125951 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 125951 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -108989,52 +109322,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -109052,7 +109385,7 @@ var ts; return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return ts.transformNodeModule; default: @@ -109091,35 +109424,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -109173,11 +109506,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -109190,7 +109523,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -109220,13 +109553,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -109250,17 +109583,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -109278,15 +109611,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -109296,23 +109629,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -109322,7 +109655,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -109338,26 +109671,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -109369,9 +109702,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -109384,8 +109717,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -109399,19 +109732,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -109420,8 +109753,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -109433,7 +109766,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -109476,8 +109809,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -109486,12 +109819,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -109505,8 +109838,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -109517,14 +109850,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -109539,7 +109872,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -109578,7 +109911,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -109644,7 +109977,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -109652,7 +109985,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -109661,7 +109994,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -109669,7 +110002,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -109683,11 +110016,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -109703,9 +110036,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -109730,20 +110063,20 @@ var ts; addOutput(buildInfoPath); } function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) { - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -109775,7 +110108,7 @@ var ts; /*@internal*/ function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; /*@internal*/ @@ -109812,17 +110145,17 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) continue; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -109831,7 +110164,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -109869,13 +110202,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -110010,7 +110343,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SyntaxKind.SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -110021,7 +110354,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -110033,8 +110366,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -110046,6 +110379,7 @@ var ts; else { printer.writeFile(sourceFile, writer, sourceMapGenerator); } + var sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -110057,7 +110391,8 @@ var ts; if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + sourceMapUrlPos = writer.getTextPos(); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { @@ -110069,13 +110404,13 @@ var ts; writer.writeLine(); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -110106,7 +110441,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -110199,8 +110534,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -110286,7 +110621,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -110338,7 +110673,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -110378,20 +110713,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -110447,11 +110782,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -110486,7 +110821,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -110497,7 +110832,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -110507,7 +110842,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -110534,7 +110869,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -110544,7 +110879,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -110583,7 +110918,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -110591,30 +110926,30 @@ var ts; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); + return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile))); } function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -110623,7 +110958,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -110639,12 +110974,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -110652,17 +110987,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -110672,7 +111007,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -110698,346 +111033,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -111049,101 +111384,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -111151,7 +111486,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -111161,7 +111496,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -111191,7 +111526,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -111233,7 +111568,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -111261,7 +111596,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -111291,9 +111626,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -111312,25 +111647,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -111338,7 +111673,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -111353,7 +111688,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -111390,7 +111725,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -111458,7 +111793,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -111568,8 +111903,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -111582,16 +111917,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -111600,10 +111935,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -111636,7 +111971,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -111650,7 +111985,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -111659,13 +111994,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -111675,7 +112010,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -111683,14 +112018,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -111698,7 +112033,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -111717,7 +112052,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -111733,12 +112068,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -111756,29 +112091,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -111804,7 +112139,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -111817,12 +112152,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111835,17 +112170,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111867,12 +112202,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -111891,22 +112226,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -111931,9 +112266,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -111974,12 +112309,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -112010,11 +112345,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -112025,7 +112360,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -112047,15 +112382,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -112098,10 +112433,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -112122,21 +112457,21 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) - if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -112146,14 +112481,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -112169,45 +112504,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -112216,12 +112551,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -112244,13 +112579,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -112290,40 +112625,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -112332,13 +112667,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -112354,7 +112689,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -112372,7 +112707,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -112409,23 +112744,23 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { return false; } - if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { + if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) { + if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -112440,14 +112775,9 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -112460,11 +112790,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -112479,15 +112809,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -112500,10 +112830,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -112526,13 +112856,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -112554,27 +112884,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112583,12 +112913,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -112599,20 +112929,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112623,37 +112953,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -112663,10 +112993,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -112674,26 +113004,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112705,7 +113035,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -112716,7 +113046,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -112735,7 +113065,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -112748,7 +113078,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -112777,7 +113107,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -112808,17 +113138,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112829,30 +113159,31 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { var emitAsSingleStatement = statements.length === 1 && ( // treat synthesized nodes as located on the same line for emit purposes - ts.nodeIsSynthesized(parentNode) || + !currentSourceFile || + ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -112860,15 +113191,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -112888,7 +113219,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -112905,7 +113236,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -112936,12 +113267,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -112975,13 +113306,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -113000,7 +113331,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -113018,14 +113349,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -113073,16 +113404,14 @@ var ts; function emitSourceFile(node) { writeLine(); var statements = node.statements; - if (emitBodyWithDetachedComments) { - // Emit detached comment if there are no prologue directives or if the first node is synthesized. - // The synthesized node will have no leading comment so some comments may be missed. - var shouldEmitDetachedComment = statements.length === 0 || - !ts.isPrologueDirective(statements[0]) || - ts.nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -113108,21 +113437,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -113130,28 +113459,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { var directive = types_24[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -113162,22 +113491,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -113198,7 +113527,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -113219,7 +113548,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -113312,7 +113641,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 262656 /* Modifiers */); + emitList(node, modifiers, 262656 /* ListFormat.Modifiers */); writeSpace(); } } @@ -113326,7 +113655,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -113356,7 +113685,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -113364,7 +113693,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -113373,19 +113702,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -113406,32 +113735,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -113447,11 +113776,11 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -113460,7 +113789,7 @@ var ts; } return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -113471,28 +113800,28 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } else { ts.Debug.type(children); // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -113503,7 +113832,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -113515,7 +113844,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -113525,14 +113854,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -113555,11 +113884,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (hasTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -113571,11 +113900,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -113584,14 +113913,14 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -113676,7 +114005,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -113726,13 +114055,13 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -113752,11 +114081,11 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild_1.kind === 11 /* JsxText */) { + if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { @@ -113769,18 +114098,18 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); } @@ -113794,7 +114123,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -113803,18 +114132,18 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -113825,7 +114154,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -113854,14 +114183,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -113870,14 +114199,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -113887,7 +114216,7 @@ var ts; if (ts.getStartsOnNewLine(node2)) { return 1; } - if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); } @@ -113897,10 +114226,10 @@ var ts; } function isEmptyBlock(block) { return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -113909,41 +114238,48 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return generateName(node); } - else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { - return ts.idText(node); - } - else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (ts.isStringLiteral(node) && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + var sourceFile = currentSourceFile; // const needed for control flow + var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node); + if (ts.isMemberName(node)) { + if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) { + return ts.idText(node); + } + } + else { + ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary + if (!canUseSourceFile) { + return node.text; + } } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -113954,7 +114290,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -113970,84 +114306,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -114056,12 +114392,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -114080,7 +114416,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -114119,7 +114455,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -114133,7 +114469,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -114143,12 +114479,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -114180,7 +114516,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -114234,48 +114570,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -114291,7 +114627,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -114302,7 +114638,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -114315,7 +114651,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -114323,7 +114659,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -114337,25 +114673,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -114365,7 +114701,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -114374,18 +114710,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -114403,25 +114739,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -114497,7 +114833,7 @@ var ts; return true; } function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); @@ -114510,7 +114846,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -114524,7 +114860,7 @@ var ts; forEachTrailingCommentToEmit(pos, emitTrailingComment); } function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { @@ -114546,15 +114882,19 @@ var ts; exitComment(); } function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); @@ -114587,6 +114927,8 @@ var ts; return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { + if (!currentSourceFile) + return; // get the leading comments from detachedPos var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { @@ -114598,7 +114940,7 @@ var ts; ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -114609,7 +114951,7 @@ var ts; } } function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); @@ -114621,7 +114963,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps function getParsedSourceMap(node) { @@ -114631,7 +114973,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -114649,12 +114991,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -114664,11 +115006,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -114721,17 +115063,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -114762,23 +115104,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -115144,7 +115486,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -115153,11 +115495,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -115167,7 +115509,7 @@ var ts; if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored - if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileOrDirectoryPath)) { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; @@ -115179,9 +115521,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -115214,7 +115556,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -115249,36 +115591,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -115288,16 +115630,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -115509,7 +115851,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -115520,7 +115862,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -115536,7 +115878,11 @@ var ts; return newValue; }; if (originalWriteFile) { - host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) { + host.writeFile = function (fileName, data) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); @@ -115550,7 +115896,7 @@ var ts; sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } // directoryExists @@ -115604,12 +115950,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -115697,9 +116043,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -115713,7 +116059,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -115776,7 +116122,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115882,7 +116228,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -116062,11 +116408,11 @@ var ts; */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { - case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; @@ -116116,7 +116462,6 @@ var ts; ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -116222,7 +116567,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -116303,16 +116648,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -116340,7 +116685,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -116349,19 +116694,19 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId }); } ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -116483,14 +116828,15 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, + writeFile: writeFile, }; onProgramCreateComplete(); // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -116502,17 +116848,52 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; + function addResolutionDiagnostics(list) { + if (!list) + return; + for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { + var elem = list_3[_i]; + programDiagnostics.add(elem); + } + } + function pullDiagnosticsFromCache(names, containingFile) { + var _a; + if (!moduleResolutionCache) + return; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + var containingDir = ts.getDirectoryPath(containingFileName); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var n = names_4[_i]; + // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less + var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + var name = typeof n === "string" ? n : n.fileName; + i++; + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + if (ts.isExternalModuleNameRelative(name)) + continue; + var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -116521,7 +116902,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -116531,7 +116912,7 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) + if (redirect || !ts.isDeclarationFileName(file.originalFileName)) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case @@ -116603,7 +116984,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -116758,22 +117139,22 @@ var ts; function tryReuseStructureFromOldProgram() { var _a; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -116781,12 +117162,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -116801,7 +117182,7 @@ var ts; ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; @@ -116810,7 +117191,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -116818,7 +117199,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -116835,9 +117216,9 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } @@ -116845,49 +117226,49 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); @@ -116908,7 +117289,7 @@ var ts; // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -116919,18 +117300,18 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping @@ -116961,7 +117342,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -116980,7 +117361,7 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, getSymlinkCache: getSymlinkCache, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + writeFile: writeFileCallback || writeFile, isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { @@ -117000,9 +117381,12 @@ var ts; getFileIncludeReasons: program.getFileIncludeReasons, }; } + function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -117054,7 +117438,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -117174,7 +117558,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -117182,8 +117566,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -117262,22 +117646,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -117285,65 +117669,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -117352,53 +117736,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 124 /* StaticKeyword */) { + if (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -117411,27 +117795,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -117501,20 +117885,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -117545,7 +117929,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -117567,7 +117951,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -117622,7 +118006,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -117737,7 +118121,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -117922,7 +118306,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -117932,7 +118316,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -117965,13 +118349,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -118010,14 +118394,14 @@ var ts; var fileName = ts.toFileNameLowerCase(ref.fileName); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); var mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { - programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { + programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, }); } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -118076,7 +118460,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -118096,7 +118480,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -118143,7 +118527,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -118204,7 +118588,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -118344,19 +118728,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -118373,7 +118757,7 @@ var ts; } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && - ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -118395,7 +118779,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -118417,7 +118801,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -118431,7 +118815,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -118439,12 +118823,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -118523,7 +118907,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -118762,7 +119146,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -118772,16 +119156,16 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -118882,12 +119266,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -118940,7 +119324,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -119036,17 +119420,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -119065,7 +119449,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -119080,7 +119464,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -119105,13 +119489,9 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - var manyToManyPathMapCount = 0; function createManyToManyPathMap() { function create(forward, reverse, deleted) { - var version = 0; var map = { - id: manyToManyPathMapCount++, - version: function () { return version; }, clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, @@ -119127,30 +119507,29 @@ var ts; } set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); forward.delete(k); - version++; return true; }, set: function (k, vSet) { - var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + deleted === null || deleted === void 0 ? void 0 : deleted.delete(k); var existingVSet = forward.get(k); forward.set(k, vSet); existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(function (v) { if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } return map; }, + clear: function () { + forward.clear(); + reverse.clear(); + deleted === null || deleted === void 0 ? void 0 : deleted.clear(); + } }; return map; } @@ -119165,11 +119544,10 @@ var ts; } set.add(v); } - function deleteFromMultimap(map, k, v, removeEmpty) { - if (removeEmpty === void 0) { removeEmpty = true; } + function deleteFromMultimap(map, k, v) { var set = map.get(k); if (set === null || set === void 0 ? void 0 : set.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -119398,7 +119776,7 @@ var ts; /*forceDtsEmit*/ true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -119448,6 +119826,7 @@ var ts; } } } + BuilderState.updateExportedModules = updateExportedModules; /** * Updates the exported modules from cache into state's exported modules map * This should be called whenever it is safe to commit the state of the builder @@ -119456,20 +119835,6 @@ var ts; var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - var cacheId = exportedModulesMapCache.id; - var cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - // If this is the same cache at the same version as last time this BuilderState - // was updated, there's no need to update again - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } @@ -119718,7 +120083,7 @@ var ts; } else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -119803,7 +120168,8 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash) { + function getNextAffectedFile(state, cancellationToken, computeHash, host) { + var _a; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -119814,7 +120180,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -119826,6 +120192,7 @@ var ts; ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); state.currentAffectedFilesSignatures.clear(); ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); state.affectedFiles = undefined; } // Get next changed file @@ -119855,6 +120222,11 @@ var ts; state.seenAffectedFiles = new ts.Set(); } } + function clearAffectedFilesPendingEmit(state) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } /** * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet */ @@ -119874,49 +120246,48 @@ var ts; } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } + function removeDiagnosticsOfLibraryFiles(state) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var program_1 = ts.Debug.checkDefined(state.program); + var options_2 = program_1.getCompilerOptions(); + ts.forEach(program_1.getSourceFiles(), function (f) { + return program_1.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2, program_1) && + removeSemanticDiagnosticsOf(state, f.resolvedPath); + }); + } + } /** * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.checkDefined(state.program); - var options_2 = program_1.getCompilerOptions(); - ts.forEach(program_1.getSourceFiles(), function (f) { - return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2, program_1) && - removeSemanticDiagnosticsOf(state, f.resolvedPath); - }); - } + removeDiagnosticsOfLibraryFiles(state); // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } - else { - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); - } - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); - } + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) + return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -119927,11 +120298,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, - /* useFileVersionAsSignature */ true); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -119953,16 +120323,41 @@ var ts; var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } + function forEachKeyOfExportedModulesMap(state, filePath, fn) { + // Go through exported modules from cache first + var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); + var result = keys && ts.forEachKey(keys, fn); + if (result) + return result; + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + keys = state.exportedModulesMap.getKeys(filePath); + return keys && ts.forEachKey(keys, function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? + fn(exportedFromPath) : + undefined; + }); + } + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + var _a; + if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) + return false; + // Every file needs to be handled + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + removeDiagnosticsOfLibraryFiles(state); + return true; + } /** - * Iterate on referencing modules that export entities from affected file + * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - var _a, _b; + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; - } if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself @@ -119975,7 +120370,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -119987,56 +120384,38 @@ var ts; var seenFileAndExportsOfFile = new ts.Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + return true; + var references = state.referencedMap.getKeys(exportedFromPath); + return references && ts.forEachKey(references, function (filePath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + }); }); } /** - * Iterate on files referencing referencedPath + * handle dts and semantic diagnostics on file and iterate on anything that exports this file + * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { var _a; - (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { - return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); - }); - } - /** - * fn on file and iterate on anything that exports this file - */ - function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { - var _a, _b, _c; - if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - fn(state, filePath); + if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) + return undefined; + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) - (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file - fn(state, referencingFilePath); - } // Dont add to seen since this is not yet done with the export removal - ); + handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal + state, referencingFilePath, cancellationToken, computeHash, host); + }); + return undefined; } /** * This is called after completing operation on the next affected file. @@ -120125,13 +120504,18 @@ var ts; var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + // If file version is same as signature, dont serialize signature + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // If file info only contains version and signature and both are same we can just write string value.version : - actualSignature !== undefined ? + actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo signature === undefined ? + // If we havent computed signature, use fileInfo as is value : + // Serialize fileInfo with new updated signature { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // Signature of the FileInfo is undefined, serialize it as false { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; @@ -120376,8 +120760,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -120390,7 +120774,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -120407,7 +120791,43 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + } + function getWriteFileUpdatingSignatureCallback(writeFile) { + return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + var _a; + if (ts.isDeclarationFileName(fileName)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; + if (signature === file.version) { + var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { // Update it + if (host.storeFilesChangingSignatureDuringEmit) + (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); + if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { + state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) + ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) + writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else + state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; } /** * Emits the JavaScript and declaration files. @@ -120421,56 +120841,52 @@ var ts; * in that order would be used to write the files */ function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var restorePendingEmitOnHandlingNoEmitSuccess = false; - var savedAffectedFilesPendingEmit; - var savedAffectedFilesPendingEmitKind; - var savedAffectedFilesPendingEmitIndex; - // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors - // This ensures pending files to emit is updated in tsbuildinfo - // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit) - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !ts.outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } + var _a; if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } // Emit only affected files if using builder for emit - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - // Emit and report any errors we ran into. - var sourceMaps = []; - var emitSkipped = false; - var diagnostics = void 0; - var emittedFiles = []; - var affectedEmitResult = void 0; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + // Emit and report any errors we ran into. + var sourceMaps = []; + var emitSkipped = false; + var diagnostics = void 0; + var emittedFiles = []; + var affectedEmitResult = void 0; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped: emitSkipped, + diagnostics: diagnostics || ts.emptyArray, + emittedFiles: emittedFiles, + sourceMaps: sourceMaps + }; + } + // In non Emit builder, clear affected files pending emit + else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) { + ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + // State can clear affected files pending emit if + if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared + // If every file pending emit is pending on only dts emit + || ts.every(state.affectedFilesPendingEmit, function (path, index) { + return index < state.affectedFilesPendingEmitIndex || + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; + })) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped: emitSkipped, - diagnostics: diagnostics || ts.emptyArray, - emittedFiles: emittedFiles, - sourceMaps: sourceMaps - }; } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** * Return the semantic diagnostics for the next affected file or undefined if iteration is complete @@ -120478,7 +120894,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { // Done return undefined; @@ -120490,7 +120906,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -120702,7 +121118,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -120759,7 +121175,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); @@ -120914,8 +121330,8 @@ var ts; !!redirectedReference; var seenNamesInFile = ts.createModeAwareCache(); var i = 0; - for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { - var entry = names_4[_i]; + for (var _i = 0, names_5 = names; _i < names_5.length; _i++) { + var entry = names_5[_i]; var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase(); // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant // they require calculating the mode for a given import from it's position in the resolution table, since a given @@ -121059,7 +121475,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -121236,7 +121652,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -121247,7 +121663,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -121387,7 +121803,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -121455,33 +121871,33 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { var _a; - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { return false; } @@ -121525,14 +121941,14 @@ var ts; if (options === void 0) { options = {}; } var info = getInfo(importingSourceFile.path, host); var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); }); } moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) { if (options === void 0) { options = {}; } var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { @@ -121589,7 +122005,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -121608,7 +122024,7 @@ var ts; var relativeSpecifiers; for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { var modulePath = modulePaths_1[_i]; - var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", @@ -121650,7 +122066,7 @@ var ts; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -121664,10 +122080,10 @@ var ts; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -121701,7 +122117,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -121709,7 +122125,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -121880,11 +122296,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -121925,23 +122341,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -121968,9 +122384,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -122001,7 +122417,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) { + function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) { var path = _a.path, isRedirect = _a.isRedirect; var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { @@ -122015,8 +122431,9 @@ var ts; var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; - var moduleFileNameForExtensionless = void 0; + var moduleFileName = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; @@ -122033,12 +122450,12 @@ var ts; isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) - moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) + moduleFileName = moduleFileToTry; // try with next level of directory packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -122066,7 +122483,7 @@ var ts; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); - if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` @@ -122090,13 +122507,13 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Ending.Minimal */, options), versionPaths.paths); if (fromPaths !== undefined) { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name - var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -122104,24 +122521,21 @@ var ts; } } } - return { moduleFileToTry: moduleFileToTry }; - } - function getExtensionlessFileName(path) { - // We still have a file name - remove the extension - var fullModulePathWithoutExtension = ts.removeFileExtension(path); - // If the file is /index, it can be imported by its directory name - // IFF there is not _also_ a file by the same name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + // No package.json exists; an index.js will still resolve as the package name + var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath }; + } } - return fullModulePathWithoutExtension; + return { moduleFileToTry: moduleFileToTry }; } } function tryGetAnyFileFromPath(host, path) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -122136,18 +122550,24 @@ var ts; return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } - function removeExtensionAndIndexPostFix(fileName, ending, options) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + function removeExtensionAndIndexPostFix(fileName, ending, options, host) { + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: - return ts.removeSuffix(noExtension, "/index"); - case 1 /* Index */: + case 0 /* Ending.Minimal */: + var withoutIndex = ts.removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + // Can't remove index if there's a file by the same name as the directory. + // Probably more callers should pass `host` so we can determine this? + return noExtension; + } + return withoutIndex; + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -122155,28 +122575,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -122258,8 +122678,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -122267,8 +122687,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -122291,7 +122711,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -122324,7 +122744,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -122337,7 +122757,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -122360,7 +122780,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -122387,9 +122807,9 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; @@ -122422,14 +122842,14 @@ var ts; var configFile = program.getCompilerOptions().configFile; if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs)) return undefined; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -122438,7 +122858,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -122562,7 +122982,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -122662,6 +123082,7 @@ var ts; createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -122721,6 +123142,7 @@ var ts; createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } ts.createProgramHost = createProgramHost; @@ -122809,6 +123231,7 @@ var ts; var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -122891,7 +123314,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -123047,10 +123470,10 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -123211,7 +123634,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -123271,7 +123694,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -123312,7 +123735,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -123553,7 +123976,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -123598,9 +124021,6 @@ var ts; function newer(date1, date2) { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); - } /*@internal*/ function isCircularBuildOrder(buildOrder) { return !!buildOrder && !!buildOrder.buildOrder; @@ -123616,8 +124036,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -124163,7 +124583,7 @@ var ts; outputFiles.forEach(function (_a) { var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; var priorChangeTime; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && ts.isDeclarationFileName(name)) { // Check for unchanged .d.ts files if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); @@ -124392,7 +124812,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -124421,7 +124841,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -124449,7 +124869,7 @@ var ts; if (!host.fileExists(inputFile)) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (!force) { @@ -124504,7 +124924,7 @@ var ts; // In addition to file timestamps, we also keep track of when a .d.ts file // had its file touched but not had its contents changed - this allows us // to skip a downstream typecheck - if (isDeclarationFile(output)) { + if (ts.isDeclarationFileName(output)) { var outputModifiedTime = ts.getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -124658,7 +125078,7 @@ var ts; reportVerbose = false; reportStatus(state, verboseMessage, proj.options.configFilePath); } - if (isDeclarationFile(file)) { + if (ts.isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); @@ -124808,7 +125228,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -124911,7 +125331,7 @@ var ts; if (!state.watch || !state.lastCachedPackageJsonLookups) return; ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { - createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, onDeleteValue: ts.closeFileWatcher, }); } @@ -125146,7 +125566,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -125157,7 +125577,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -125210,7 +125630,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -125283,7 +125703,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -125297,7 +125717,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -125306,7 +125726,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -125328,7 +125748,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -125356,7 +125776,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -125372,7 +125792,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -125391,12 +125811,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -125422,7 +125842,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -125450,16 +125870,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -125467,20 +125887,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -125491,17 +125911,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -125656,6 +126076,17 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + // Do not change existing values, as they exist in telemetry. + var CompletionInfoFlags; + (function (CompletionInfoFlags) { + CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports"; + CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion"; + CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets"; + })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {})); var OutliningSpanKind; (function (OutliningSpanKind) { /** Single or multi-line comments */ @@ -125862,7 +126293,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -125873,66 +126304,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -125940,7 +126371,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -125949,24 +126380,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -125974,11 +126405,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -125990,27 +126421,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -126019,17 +126450,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -126096,7 +126527,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -126157,22 +126588,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -126196,17 +126627,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -126214,108 +126645,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -126380,42 +126811,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -126424,66 +126855,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -126500,7 +126931,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -126543,13 +126974,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -126608,11 +127039,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -126702,30 +127133,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -126751,7 +127182,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -126767,13 +127198,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -126792,12 +127223,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -126805,13 +127236,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -126822,20 +127253,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -126850,29 +127281,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -126943,23 +127374,23 @@ var ts; // position and whose end is greater than the position. var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input if (nodeContainsPosition(children[middle])) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -126985,7 +127416,7 @@ var ts; return false; } var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -127054,7 +127485,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -127066,11 +127497,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -127095,7 +127526,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -127126,7 +127557,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -127162,25 +127593,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -127199,10 +127630,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -127211,17 +127642,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -127311,10 +127742,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -127324,56 +127755,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -127405,52 +127836,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -127458,7 +127889,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -127468,9 +127899,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -127483,18 +127914,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -127502,7 +127933,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -127525,8 +127956,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -127564,32 +127995,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -127598,7 +128029,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -127626,7 +128057,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -127641,7 +128072,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -127668,6 +128099,14 @@ var ts; return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } }); } ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost; + function moduleResolutionRespectsExports(moduleResolution) { + return moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports; + function moduleResolutionUsesNodeModules(moduleResolution) { + return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules; function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) { return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined; } @@ -127682,7 +128121,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -127691,25 +128130,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -127720,12 +128159,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -127769,7 +128208,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -127947,34 +128386,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -128051,7 +128490,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -128078,8 +128517,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -128129,22 +128568,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -128154,7 +128593,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -128182,10 +128621,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -128274,14 +128713,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -128300,7 +128739,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -128317,7 +128756,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -128374,7 +128813,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -128400,7 +128839,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -128408,15 +128847,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -128427,15 +128866,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -128444,10 +128883,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -128467,9 +128906,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -128481,48 +128920,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -128542,12 +128981,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -128571,7 +129010,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -128580,10 +129019,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -128707,16 +129146,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -128811,7 +129250,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -128931,20 +129370,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -128977,7 +129416,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -128995,7 +129434,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -129008,7 +129447,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -129028,7 +129467,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -129100,7 +129539,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -129109,7 +129548,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -129117,8 +129556,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -129207,9 +129646,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -129222,7 +129661,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -129271,8 +129710,8 @@ var ts; if (from === to) return false; var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {}); - if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) { - return cachedResult.isAutoImportable; + if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) { + return !cachedResult.isBlockedByPackageJsonDependencies; } var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); @@ -129286,7 +129725,7 @@ var ts; }); if (packageJsonFilter) { var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); - moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable); return isAutoImportable; } return hasImportablePath; @@ -129311,7 +129750,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -129348,24 +129787,31 @@ var ts; (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results"); var compilerOptions = program.getCompilerOptions(); var moduleCount = 0; - forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { - if (++moduleCount % 100 === 0) - cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); - var seenExports = new ts.Map(); - var checker = program.getTypeChecker(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - // Note: I think we shouldn't actually see resolved module symbols here, but weird merges - // can cause it to happen: see 'completionsImport_mergedReExport.ts' - if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); - } - checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { - if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + try { + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { + if (++moduleCount % 100 === 0) + cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); + var seenExports = new ts.Map(); + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + // Note: I think we shouldn't actually see resolved module symbols here, but weird merges + // can cause it to happen: see 'completionsImport_mergedReExport.ts' + if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } + checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); + } + }); }); - }); - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + } + catch (err) { + // Ensure cache is reset if operation is cancelled + cache.clear(); + throw err; + } + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -129384,10 +129830,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -129396,7 +129842,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -129406,8 +129852,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -129419,7 +129865,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -129429,15 +129875,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -129463,10 +129909,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -129502,68 +129948,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -129572,15 +130018,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -129594,59 +130040,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -129688,23 +130134,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -129718,10 +130164,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -129734,19 +130180,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -129754,47 +130200,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -129802,12 +130248,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -129815,36 +130261,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -129864,13 +130310,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -129895,10 +130341,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -129907,29 +130353,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -129938,35 +130384,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -129992,11 +130438,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -130018,12 +130464,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -130031,21 +130477,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -130054,7 +130500,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -130065,7 +130511,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -130074,7 +130520,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -130087,51 +130533,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -130150,7 +130596,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -130160,7 +130606,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -130185,9 +130631,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -130201,19 +130647,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -130221,7 +130667,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -130245,7 +130691,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -130272,10 +130718,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -130288,24 +130734,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -130316,97 +130762,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -130482,14 +130928,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -130501,13 +130947,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -130523,7 +130969,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -130532,38 +130978,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -130576,22 +131022,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -130601,17 +131047,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -130653,25 +131099,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -130702,19 +131148,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -130733,16 +131179,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -130758,20 +131204,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -130785,18 +131231,18 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { + case 196 /* SyntaxKind.LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -130808,21 +131254,21 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -130839,7 +131285,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -130852,41 +131298,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -130913,14 +131359,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -130929,10 +131375,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -130943,13 +131389,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -130971,11 +131417,11 @@ var ts; : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -130989,11 +131435,11 @@ var ts; } function isEmitResolutionKindUsingNodeModules(compilerOptions) { return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs || - ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function isEmitModuleResolutionRespectingExportMaps(compilerOptions) { - return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -131068,16 +131514,16 @@ var ts; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } var foundFileName = void 0; var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { + else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); foundFiles.set(foundFileName, outputExtension); } @@ -131087,7 +131533,7 @@ var ts; } } foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + result.push(nameAndKind(foundFile, "script" /* ScriptElementKind.scriptElement */, ext)); }); } // If possible, get folder completion as well @@ -131158,7 +131604,7 @@ var ts; var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -131169,7 +131615,7 @@ var ts; var _loop_4 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -131230,7 +131676,7 @@ var ts; }); ts.forEach(processedKeys, function (k) { if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(k, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }); return; @@ -131289,7 +131735,7 @@ var ts; var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); + return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* ScriptElementKind.scriptElement */, extension); }); var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); @@ -131334,7 +131780,7 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, names); @@ -131365,7 +131811,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -131407,14 +131853,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -131471,7 +131917,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -131513,16 +131959,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -131531,16 +131977,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -131553,7 +131999,7 @@ var ts; KeywordCompletionFilters[KeywordCompletionFilters["TypeAssertionKeywords"] = 6] = "TypeAssertionKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeywords"] = 7] = "TypeKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeyword"] = 8] = "TypeKeyword"; - KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 7] = "Last"; + KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 8] = "Last"; })(KeywordCompletionFilters || (KeywordCompletionFilters = {})); var GlobalsSearch; (function (GlobalsSearch) { @@ -131561,43 +132007,54 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) { + function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) { var _a, _b, _c; var start = ts.timestamp(); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - var resolutionLimitExceeded = false; + // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because + // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a + // relative path into node_modules), and we want to filter those completions out entirely. + // Import statement completions always need specifier resolution because the module specifier is + // part of their `insertText`, not the `codeActions` creating edits away from the cursor. + var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions())); + var skippedAny = false; var ambientCount = 0; var resolvedCount = 0; var resolvedFromCacheCount = 0; var cacheAttemptCount = 0; - var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var result = cb({ + tryResolve: tryResolve, + skippedAny: function () { return skippedAny; }, + resolvedAny: function () { return resolvedCount > 0; }, + resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, + }); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; - function tryResolve(exportInfo, isFromAmbientModule) { + function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { - var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences); + var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences); if (result_1) { ambientCount++; } - return result_1; + return result_1 || "failed"; } - var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; + var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit; var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache) - ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) + ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) : undefined; if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) { - resolutionLimitExceeded = true; + skippedAny = true; } resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0; - resolvedFromCacheCount += exportInfo.length - resolvedCount; + resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0); if (shouldGetModuleSpecifierFromCache) { cacheAttemptCount++; } - return result; + return result || (needsFullResolution ? "failed" : "skipped"); } } function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) { @@ -131617,7 +132074,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -131631,7 +132088,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -131639,21 +132096,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -131670,16 +132127,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -131692,9 +132149,10 @@ var ts; return undefined; var lowerCaseTokenText = location.text.toLowerCase(); var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken); - var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences, - /*isForImportStatementCompletion*/ false, function (context) { + var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences, + /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) { var entries = ts.mapDefined(previousResponse.entries, function (entry) { + var _a; if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) { // Not an auto import or already resolved; keep as is return entry; @@ -131705,10 +132163,14 @@ var ts; } var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin; var info = exportMap.get(file.path, entry.data.exportMapKey); - var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); - if (!result) + var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); + if (result === "skipped") return entry; - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + if (!result || result === "failed") { + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); + return undefined; + } + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -131716,12 +132178,13 @@ var ts; entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)]; return entry; }); - if (!context.resolutionLimitExceeded()) { + if (!context.skippedAny()) { previousResponse.isIncomplete = undefined; } return entries; }); previousResponse.entries = newEntries; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -131730,8 +132193,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -131745,25 +132208,25 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; @@ -131776,17 +132239,17 @@ var ts; getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { + if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { return undefined; } getCompletionEntriesFromSymbols(symbols, entries, /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); } - if (keywordFilters !== 0 /* None */) { + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (!entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } @@ -131803,12 +132266,13 @@ var ts; ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); } return { + flags: completionData.flags, isGlobalCompletion: isInSnippetScope, isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, optionalReplacementSpan: getOptionalReplacementSpan(location), - entries: entries + entries: entries, }; } function isUncheckedFile(sourceFile, compilerOptions) { @@ -131816,9 +132280,9 @@ var ts; } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -131828,12 +132292,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -131852,14 +132316,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -131878,7 +132342,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -131891,7 +132355,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -131908,18 +132372,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -131930,7 +132394,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -131943,8 +132407,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -131954,12 +132418,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -131970,28 +132434,24 @@ var ts; } } if (origin && originIsObjectLiteralMethod(origin)) { - var importAdder = void 0; - (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails); + (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails); if (!preferences.useLabelDetailsInCompletionEntries) { name = name + labelDetails.detail; labelDetails = undefined; } source = CompletionSource.ObjectLiteralMethodSnippet; sortText = Completions.SortText.SortBelow(sortText); - if (importAdder.hasFixes()) { - hasAction = true; - } } if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -132000,7 +132460,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -132042,8 +132502,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -132102,16 +132562,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -132122,13 +132582,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -132139,9 +132599,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -132156,9 +132616,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -132203,8 +132663,7 @@ var ts; var isSnippet = preferences.includeCompletionsWithSnippetText || undefined; var insertText = name; var sourceFile = enclosingDeclaration.getSourceFile(); - var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host); - var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder); + var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences); if (!method) { return undefined; } @@ -132216,10 +132675,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -132232,33 +132691,32 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; - return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; + return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; - function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) { + function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } var checker = program.getTypeChecker(); - var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var declaration = declarations[0]; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -132266,7 +132724,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -132275,47 +132733,72 @@ var ts; if (!typeNode || !ts.isFunctionTypeNode(typeNode)) { return undefined; } - var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); - if (importableReference) { - typeNode = importableReference.typeNode; - ts.codefix.importSymbols(importAdder, importableReference.symbols); - } var body = void 0; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } + var parameters = typeNode.parameters.map(function (typedParam) { + return ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken, + /*type*/ undefined, typedParam.initializer); + }); return ts.factory.createMethodDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, - /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body); + /*questionToken*/ undefined, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } default: return undefined; } } function createSnippetPrinter(printerOptions) { + var escapes; var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions)); var printer = ts.createPrinter(printerOptions, baseWriter); - var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } }); + var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } }); return { printSnippetList: printSnippetList, printAndFormatSnippetList: printAndFormatSnippetList, }; + // The formatter/scanner will have issues with snippet-escaped text, + // so instead of writing the escaped text directly to the writer, + // generate a set of changes that can be applied to the unescaped text + // to escape it post-formatting. + function escapingWrite(s, write) { + var escaped = ts.escapeSnippetText(s); + if (escaped !== s) { + var start = baseWriter.getTextPos(); + write(); + var end = baseWriter.getTextPos(); + escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } }); + } + else { + write(); + } + } /* Snippet-escaping version of `printer.printList`. */ function printSnippetList(format, list, sourceFile) { + var unescaped = printUnescapedSnippetList(format, list, sourceFile); + return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped; + } + function printUnescapedSnippetList(format, list, sourceFile) { + escapes = undefined; writer.clear(); printer.writeList(format, list, sourceFile, writer); return writer.getText(); } function printAndFormatSnippetList(format, list, sourceFile, formatContext) { var syntheticFile = { - text: printSnippetList(format, list, sourceFile), + text: printUnescapedSnippetList(format, list, sourceFile), getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); }, @@ -132327,7 +132810,10 @@ var ts; /* indentation */ 0, /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions })); }); - return ts.textChanges.applyChanges(syntheticFile.text, changes); + var allChanges = escapes + ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); }) + : changes; + return ts.textChanges.applyChanges(syntheticFile.text, allChanges); } } function originToCompletionEntryData(origin) { @@ -132353,11 +132839,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -132369,7 +132855,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -132385,21 +132871,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -132410,7 +132896,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -132419,10 +132905,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -132441,7 +132927,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -132494,7 +132980,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -132502,7 +132988,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -132526,8 +133012,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -132558,7 +133044,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -132572,8 +133058,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -132593,14 +133079,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -132612,22 +133098,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -132656,20 +133142,6 @@ var ts; }; } } - if (source === CompletionSource.ObjectLiteralMethodSnippet) { - var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken); - var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder; - if (importAdder.hasFixes()) { - var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes); - return { - sourceDisplay: undefined, - codeActions: [{ - changes: changes, - description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]), - }], - }; - } - } if (originIsTypeOnlyAlias(origin)) { var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences); ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias"); @@ -132681,7 +133153,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -132713,7 +133185,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -132721,31 +133193,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -132753,14 +133225,14 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -132776,10 +133248,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -132800,7 +133272,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -132810,21 +133282,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -132855,15 +133327,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -132876,6 +133349,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -132885,11 +133359,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -132897,7 +133371,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -132905,18 +133379,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -132924,58 +133398,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -132983,16 +133457,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -133001,7 +133475,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -133020,8 +133494,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -133029,8 +133503,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -133044,10 +133518,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -133068,16 +133542,17 @@ var ts; isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, + flags: flags, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -133086,13 +133561,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -133107,7 +133582,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -133115,7 +133590,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -133129,7 +133604,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -133143,7 +133618,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -133167,7 +133642,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -133175,7 +133650,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; if (inUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -133222,21 +133697,21 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, symbol: firstAccessibleSymbol, targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags, - }], sourceFile, program, host, preferences) || {}).moduleSpecifier; + }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -133267,15 +133742,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -133291,44 +133766,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -133363,7 +133838,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -133373,21 +133848,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -133396,8 +133871,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -133421,10 +133896,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -133440,29 +133915,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -133477,6 +133952,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -133488,50 +133964,72 @@ var ts; var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken); var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host); var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host); - resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) { + resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) { exportInfo.search(sourceFile.path, /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) { if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings()))) return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText); }, function (info, symbolName, isFromAmbientModule, exportMapKey) { + var _a; if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) { return; } - var defaultExportInfo = ts.find(info, isImportableExportInfo); - if (!defaultExportInfo) { + // Do a relatively cheap check to bail early if all re-exports are non-importable + // due to file location or package.json dependency filtering. For non-node16+ + // module resolution modes, getting past this point guarantees that we'll be + // able to generate a suitable module specifier, so we can safely show a completion, + // even if we defer computing the module specifier. + var firstImportableExportInfo = ts.find(info, isImportableExportInfo); + if (!firstImportableExportInfo) { return; } - // If we don't need to resolve module specifiers, we can use any re-export that is importable at all - // (We need to ensure that at least one is importable to show a completion.) - var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier; - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + // In node16+, module specifier resolution can fail due to modules being blocked + // by package.json `exports`. If that happens, don't show a completion item. + // N.B. in this resolution mode we always try to resolve module specifiers here, + // because we have to know now if it's going to fail so we can omit the completion + // from the list. + var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {}; + if (result === "failed") + return; + // If we skipped resolving module specifiers, our selection of which ExportInfo + // to use here is arbitrary, since the info shown in the completion list derived from + // it should be identical regardless of which one is used. During the subsequent + // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick + // the best one based on the module specifier it produces. + var exportInfo = firstImportableExportInfo, moduleSpecifier; + if (result !== "skipped") { + (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); + } + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, isFromPackageJson: exportInfo.isFromPackageJson, }); }); - hasUnresolvedAutoImports = context.resolutionLimitExceeded(); + hasUnresolvedAutoImports = context.skippedAny(); + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -133568,7 +134066,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -133578,7 +134076,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -133593,7 +134092,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -133620,27 +134119,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -133651,45 +134150,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -133708,21 +134207,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -133734,22 +134233,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -133759,12 +134258,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -133775,19 +134274,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -133799,14 +134298,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -133823,38 +134322,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -133867,14 +134366,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -133883,7 +134382,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -133892,48 +134391,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -133947,8 +134446,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -133978,23 +134477,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134005,8 +134504,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134014,10 +134513,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134025,7 +134524,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134044,75 +134543,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -134133,21 +134632,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -134156,7 +134655,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -134167,7 +134666,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -134183,22 +134682,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -134216,13 +134715,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -134235,7 +134734,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -134269,7 +134768,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -134294,7 +134793,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -134313,10 +134812,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -134324,11 +134823,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -134339,7 +134838,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -134358,7 +134857,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -134381,15 +134880,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -134412,12 +134911,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -134426,27 +134925,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -134456,11 +134955,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -134469,7 +134968,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 7 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -134478,30 +134977,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -134509,63 +135008,63 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -134586,9 +135085,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -134604,7 +135103,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -134626,7 +135125,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -134634,7 +135133,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -134652,15 +135151,15 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -134674,22 +135173,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -134700,7 +135199,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -134709,15 +135208,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -134734,11 +135233,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -134760,13 +135259,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -134779,22 +135278,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -134802,7 +135301,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -134819,7 +135318,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -134827,23 +135326,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -134853,12 +135352,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -134898,8 +135397,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -134936,8 +135435,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -134951,7 +135450,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -134981,7 +135480,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -135011,45 +135510,47 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); + case 101 /* SyntaxKind.InKeyword */: + return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -135091,7 +135592,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -135123,16 +135624,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -135148,41 +135649,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -135201,12 +135702,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -135214,7 +135715,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -135223,13 +135724,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -135237,13 +135738,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -135251,13 +135752,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -135268,13 +135769,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -135286,11 +135787,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -135302,13 +135803,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -135323,7 +135824,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -135342,7 +135843,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -135357,7 +135858,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -135377,10 +135878,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -135464,7 +135965,7 @@ var ts; } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { @@ -135472,7 +135973,7 @@ var ts; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); var sourceFileOptions = { languageVersion: scriptTarget, impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), @@ -135485,15 +135986,15 @@ var ts; // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). - var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) && + var otherBucketKey = !ts.isDeclarationFileName(path) && ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); } } var bucketEntry = bucket.get(path); @@ -135607,18 +136108,18 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -135685,43 +136186,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -135730,7 +136231,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -135752,18 +136253,18 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* SyntaxKind.ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -135785,7 +136286,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -135819,33 +136320,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -135854,12 +136355,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -135870,7 +136371,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -135882,7 +136383,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -135907,7 +136408,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -135916,7 +136417,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -135936,7 +136437,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -135984,7 +136485,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -135999,15 +136500,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -136032,7 +136533,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -136045,21 +136546,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -136077,24 +136578,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -136121,22 +136622,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -136166,16 +136667,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; @@ -136205,7 +136706,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -136216,21 +136717,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -136257,7 +136758,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -136285,7 +136786,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -136324,7 +136825,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -136333,7 +136834,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -136341,28 +136842,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -136403,7 +136904,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -136420,19 +136921,19 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } else { @@ -136455,18 +136956,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -136474,7 +136975,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -136493,7 +136994,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -136501,32 +137002,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -136534,7 +137035,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -136557,19 +137058,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -136579,7 +137080,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -136587,10 +137088,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -136624,12 +137125,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -136637,16 +137138,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -136655,17 +137156,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -136680,14 +137181,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -136695,9 +137196,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -136708,50 +137209,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -136780,7 +137281,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -136802,7 +137303,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -136812,11 +137313,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -136827,10 +137328,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -136858,7 +137359,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -136878,10 +137379,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -136909,13 +137410,13 @@ var ts; continue; } var _loop_5 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -136946,7 +137447,7 @@ var ts; return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -136967,7 +137468,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -136977,21 +137478,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -136999,41 +137500,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -137049,7 +137550,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -137058,20 +137559,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -137094,17 +137595,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -137117,10 +137618,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -137134,7 +137635,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -137186,7 +137687,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -137209,7 +137710,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -137217,7 +137718,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -137248,19 +137749,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -137273,7 +137774,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -137301,13 +137802,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -137317,7 +137818,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -137343,17 +137844,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -137370,7 +137871,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -137382,7 +137883,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -137430,6 +137931,30 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function getTopMostDeclarationNamesInFile(declarationName, sourceFile) { + var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); }); + return candidates.reduce(function (topMost, decl) { + var depth = getDepth(decl); + if (!ts.some(topMost.declarationNames) || depth === topMost.depth) { + topMost.declarationNames.push(decl); + topMost.depth = depth; + } + else if (depth < topMost.depth) { + topMost.declarationNames = [decl]; + topMost.depth = depth; + } + return topMost; + }, { depth: Infinity, declarationNames: [] }).declarationNames; + function getDepth(declaration) { + var depth = 0; + while (declaration) { + declaration = ts.getContainerNode(declaration); + depth++; + } + return depth; + } + } + Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile; function someSignatureUsage(signature, sourceFiles, checker, cb) { if (!signature.name || !ts.isIdentifier(signature.name)) return false; @@ -137477,8 +138002,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -137493,27 +138018,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -137529,7 +138054,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -137540,7 +138065,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -137591,7 +138116,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -137601,14 +138126,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -137616,7 +138141,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -137636,7 +138161,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -137646,7 +138171,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -137657,9 +138182,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -137667,7 +138192,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -137694,11 +138219,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -137718,14 +138243,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -137743,7 +138268,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -137759,7 +138284,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -137770,7 +138295,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -137789,18 +138314,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -137811,7 +138336,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -137821,10 +138346,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -137848,10 +138373,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -137871,7 +138396,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -137899,13 +138424,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -137956,15 +138481,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -137973,7 +138498,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -137982,46 +138507,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -138029,26 +138554,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -138061,18 +138586,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -138117,30 +138642,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -138150,14 +138675,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -138172,7 +138697,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -138180,7 +138705,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -138192,13 +138717,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -138220,7 +138745,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -138234,12 +138759,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -138249,7 +138774,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -138289,7 +138814,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -138300,7 +138825,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -138329,12 +138854,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -138354,7 +138879,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -138403,7 +138928,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -138427,8 +138952,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -138448,7 +138973,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -138461,16 +138986,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -138568,7 +139093,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -138579,7 +139104,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -138609,7 +139134,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -138639,7 +139164,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -138667,7 +139192,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -138684,59 +139209,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -138753,7 +139278,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -138792,25 +139317,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -138826,7 +139351,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -139066,7 +139591,9 @@ var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { - function getDefinitionAtPosition(program, sourceFile, position) { + function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) { + var _a; + var _b; var resolvedRef = getReferenceAtPosition(sourceFile, position, program); var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { @@ -139079,45 +139606,75 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; - var symbol_1 = getSymbol(classDecl, typeChecker); + var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution; var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration); var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : ""; var sourceFile_1 = node.getSourceFile(); return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } - var symbol = getSymbol(node, typeChecker); + var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; + var fallbackNode = node; + if (searchOtherFilesOnly && failedAliasResolution) { + // We couldn't resolve the specific import, try on the module specifier. + var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); }); + var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration); + if (moduleSpecifier) { + (_a = getSymbol(moduleSpecifier, typeChecker, stopAtAlias), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution); + fallbackNode = moduleSpecifier; + } + } + if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) { + // We couldn't resolve the module specifier as an external module, but it could + // be that module resolution succeeded but the target was not a module. + var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode)); + if (ref) { + return [{ + name: fallbackNode.text, + fileName: ref.resolvedFileName, + containerName: undefined, + containerKind: undefined, + kind: "script" /* ScriptElementKind.scriptElement */, + textSpan: ts.createTextSpan(0, 0), + failedAliasResolution: failedAliasResolution, + isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), + unverified: fallbackNode !== node, + }]; + } + } // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } + if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; })) + return undefined; var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) { - var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); + var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) { return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -139125,9 +139682,9 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray; + var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the @@ -139150,7 +139707,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -139248,24 +139805,24 @@ var ts; return undefined; } if (ts.isImportMeta(node.parent) && node.parent.name === node) { - return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent); + return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false); } - var symbol = getSymbol(node, typeChecker); + var _a = getSymbol(node, typeChecker, /*stopAtAlias*/ false), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution; if (!symbol) return undefined; var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node); var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker); - var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node); + var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution); // If a function returns 'void' or some other type with no definition, just return the function definition. - var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node); + var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; - function definitionFromType(type, checker, node) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { - return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node); + function definitionFromType(type, checker, node, failedAliasResolution) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { + return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } function tryGetReturnTypeOfFunction(symbol, type, checker) { @@ -139301,19 +139858,23 @@ var ts; function getDefinitionInfoForIndexSignatures(node, checker) { return ts.mapDefined(checker.getIndexInfosAtLocation(node), function (info) { return info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); }); } - function getSymbol(node, checker) { + function getSymbol(node, checker, stopAtAlias) { var symbol = checker.getSymbolAtLocation(node); // If this is an alias, and the request came at the declaration location // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + var failedAliasResolution = false; + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { - return aliased; + return { symbol: aliased }; + } + else { + failedAliasResolution = true; } } - return symbol; + return { symbol: symbol, failedAliasResolution: failedAliasResolution }; } // Go to the original declaration for cases: // @@ -139321,36 +139882,55 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - switch (declaration.kind) { - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: - return true; - case 270 /* ImportSpecifier */: - return declaration.parent.kind === 269 /* NamedImports */; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); - default: - return false; + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { + return false; } + return true; } - function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { - // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties. - // For deduping purposes, we also want to exclude any declarationNodes if provided. - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) - || undefined; - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + /** + * ```ts + * function f() {} + * f.foo = 0; + * ``` + * + * Here, `f` has two declarations: the function declaration, and the identifier in the next line. + * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so + * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a + * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this + * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the + * declaration looks like an assignment, that declaration is in no sense a definition for `f`. + * But that information is totally lost during binding and/or symbol merging, so we need to do + * our best to reconstruct it or use other heuristics. This function (and the logic around its + * calling) covers our tests but feels like a hack, and it would be great if someone could come + * up with a more precise definition of what counts as a definition. + */ + function isExpandoDeclaration(node) { + if (!ts.isAssignmentDeclaration(node)) + return false; + var containingAssignment = ts.findAncestor(node, function (p) { + if (ts.isAssignmentExpression(p)) + return true; + if (!ts.isAssignmentDeclaration(p)) + return "quit"; + return false; + }); + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; + } + function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); + var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); }); + var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -139370,26 +139950,27 @@ var ts; return declarations.length ? declarationsWithBody.length !== 0 ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) - : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)] : undefined; } } /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ - function createDefinitionInfo(declaration, checker, symbol, node) { + function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) { var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node); var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : ""; - return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName); + return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution); } + GoToDefinition.createDefinitionInfo = createDefinitionInfo; /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) { + function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) { var sourceFile = declaration.getSourceFile(); if (!textSpan) { var name = ts.getNameOfDeclaration(declaration) || declaration; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -139401,29 +139982,29 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; } } - function createDefinitionFromSignatureDeclaration(typeChecker, decl) { - return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); + function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) { + return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution); } function findReferenceInPosition(refs, pos) { return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); @@ -139433,7 +140014,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -139454,9 +140035,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -139568,10 +140149,10 @@ var ts; // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = getDisplayPartsFromComment(jsdoc.comment, checker); @@ -139588,11 +140169,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -139606,8 +140187,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -139622,17 +140203,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -139646,7 +140227,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -139654,13 +140235,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -139687,14 +140268,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -139704,7 +140285,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -139715,8 +140296,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -139726,7 +140307,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139752,14 +140333,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139846,37 +140427,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -139886,25 +140467,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -139917,14 +140498,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -139983,9 +140564,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -139995,7 +140576,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -140012,7 +140593,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -140046,7 +140627,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -140229,7 +140810,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -140242,7 +140823,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -140254,25 +140835,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -140284,7 +140865,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -140295,17 +140876,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -140315,7 +140896,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -140323,11 +140904,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -140337,9 +140918,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -140347,10 +140928,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -140364,27 +140945,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -140398,7 +140979,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -140418,10 +140999,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -140434,7 +141015,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -140452,9 +141033,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -140510,16 +141091,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -140527,10 +141108,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -140596,7 +141177,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -140615,12 +141196,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -140628,7 +141209,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -140642,7 +141223,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -140672,7 +141253,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -140681,53 +141262,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -140760,19 +141341,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -140782,10 +141363,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -140847,7 +141428,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -140861,13 +141442,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -140882,7 +141463,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -140890,7 +141471,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -140901,10 +141482,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -140917,7 +141498,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -140925,9 +141506,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -141041,7 +141622,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -141059,7 +141640,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -141328,11 +141909,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -141371,19 +141952,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -141436,7 +142017,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -141444,7 +142025,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -141494,7 +142075,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -141529,7 +142110,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -141545,9 +142126,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -141558,7 +142139,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -141572,7 +142153,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -141580,23 +142161,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -141604,52 +142185,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -141660,33 +142241,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -141695,32 +142276,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -141730,12 +142311,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -141861,7 +142442,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -141913,7 +142494,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -141990,10 +142571,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -142003,10 +142584,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -142031,10 +142612,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -142043,10 +142624,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -142115,35 +142696,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -142204,7 +142785,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -142225,10 +142806,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -142258,12 +142839,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -142275,54 +142856,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -142331,18 +142912,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -142350,15 +142931,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -142374,31 +142955,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -142406,31 +142987,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -142444,12 +143025,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -142460,16 +143041,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -142478,15 +143059,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -142514,31 +143095,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -142625,13 +143206,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -142644,14 +143225,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -142660,7 +143241,7 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { @@ -142671,7 +143252,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -142681,7 +143262,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -142711,13 +143292,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -142749,7 +143330,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -142817,7 +143398,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -142874,26 +143455,26 @@ var ts; if (ts.isMappedTypeNode(node)) { var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -142905,7 +143486,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -142918,14 +143499,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -142981,7 +143562,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -142996,25 +143577,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -143061,7 +143642,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -143075,27 +143656,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -143105,20 +143686,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -143154,7 +143735,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -143171,7 +143752,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -143214,7 +143795,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -143224,10 +143805,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -143252,7 +143833,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -143262,7 +143843,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -143291,28 +143872,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -143322,7 +143903,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -143344,7 +143925,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -143363,8 +143944,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -143402,7 +143983,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -143433,7 +144014,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -143445,7 +144026,7 @@ var ts; var _loop_9 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; @@ -143465,17 +144046,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -143532,10 +144113,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -143568,9 +144149,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -143578,33 +144159,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -143617,7 +144198,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -143638,14 +144219,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -143681,25 +144262,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -143713,7 +144294,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name)) { @@ -143785,17 +144366,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -143804,7 +144385,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -143827,7 +144408,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -143869,13 +144450,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -143937,7 +144518,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -144046,7 +144627,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -144082,7 +144663,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -144104,16 +144685,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -144125,12 +144706,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -144200,26 +144781,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -144232,28 +144813,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -144266,32 +144847,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -144299,52 +144880,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -144352,23 +144933,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -144378,10 +144959,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -144389,10 +144970,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -144403,41 +144984,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -144457,7 +145038,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -144465,21 +145046,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -144488,29 +145069,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -144520,31 +145101,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -144554,63 +145135,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -144621,7 +145202,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -144629,21 +145210,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -144651,22 +145232,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -144675,7 +145256,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -144691,42 +145272,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -144736,30 +145317,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144770,17 +145351,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -144796,14 +145377,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -144854,23 +145435,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -144885,31 +145466,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -144921,7 +145502,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144933,16 +145514,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -145147,8 +145728,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -145166,8 +145747,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -145179,7 +145760,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -145207,7 +145788,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -145235,11 +145816,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -145247,12 +145828,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -145261,29 +145842,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -145315,7 +145896,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -145326,40 +145907,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -145368,15 +145949,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -145443,8 +146024,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -145456,263 +146037,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -145730,7 +146311,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -145771,54 +146352,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -145830,22 +146411,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -145871,34 +146452,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -145907,40 +146488,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -145949,71 +146530,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -146028,45 +146609,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -146077,28 +146658,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -146120,15 +146701,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -146137,25 +146718,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -146184,17 +146765,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -146243,12 +146824,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -146274,7 +146855,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -146343,16 +146924,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -146374,12 +146955,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -146387,7 +146968,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -146396,7 +146977,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -146436,17 +147017,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -146543,11 +147124,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -146561,7 +147142,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -146589,7 +147170,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -146634,7 +147215,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -146649,7 +147230,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -146662,8 +147243,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -146686,19 +147267,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -146713,12 +147294,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -146745,26 +147326,26 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: - case 228 /* ExpressionWithTypeArguments */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -146799,7 +147380,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -146812,6 +147393,9 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + if (ts.nodeIsMissing(child)) { + return inheritedIndentation; + } var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; var undecoratedChildStartLine = childStartLine; @@ -146819,10 +147403,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -146858,17 +147442,17 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -146878,7 +147462,14 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; - if (listStartToken !== 0 /* Unknown */) { + // node range is outside the target range - do not dive inside + if (!ts.rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { + if (nodes.end < originalRange.pos) { + formattingScanner.skipToEndOf(nodes); + } + return; + } + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -146891,7 +147482,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -146910,15 +147501,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */ && ts.isCallLikeExpression(parent)) { var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; if (startLine !== commaTokenLine) { formattingScanner.advance(); @@ -146942,7 +147533,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -146952,13 +147543,13 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } @@ -146968,15 +147559,15 @@ var ts; if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -146990,19 +147581,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -147020,7 +147611,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -147041,7 +147632,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -147049,14 +147640,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -147065,15 +147656,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -147099,7 +147690,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -147230,48 +147821,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -147313,53 +147904,53 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -147445,7 +148036,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -147481,21 +148072,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -147515,7 +148106,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -147540,9 +148131,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -147551,7 +148142,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -147605,12 +148196,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -147649,7 +148240,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -147660,9 +148251,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -147675,13 +148266,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -147691,9 +148282,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -147708,8 +148299,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -147789,42 +148380,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -147842,27 +148433,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -147871,7 +148462,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -147881,7 +148472,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -147902,7 +148493,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -147918,98 +148509,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -148020,11 +148611,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -148114,7 +148705,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -148198,7 +148789,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -148241,7 +148832,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -148347,7 +148938,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -148411,7 +149002,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -148464,7 +149055,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -148473,19 +149064,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -148626,8 +149217,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -148635,22 +149226,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -148659,28 +149250,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -148735,7 +149326,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -148752,12 +149343,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -148780,7 +149371,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -148857,10 +149448,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -148872,16 +149463,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -148890,8 +149481,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -148911,7 +149502,7 @@ var ts; var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); var _loop_12 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. @@ -148938,8 +149529,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -148994,7 +149585,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -149002,7 +149593,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -149012,7 +149603,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -149223,7 +149814,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -149263,7 +149854,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -149275,18 +149866,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -149297,17 +149888,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -149315,13 +149906,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -149330,17 +149921,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -149369,7 +149960,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -149391,15 +149982,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -149408,14 +149999,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -149602,8 +150193,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -149688,7 +150279,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -149738,7 +150329,7 @@ var ts; ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, - ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, + ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code, @@ -149832,12 +150423,12 @@ var ts; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -149905,15 +150496,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -150002,7 +150593,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -150026,16 +150617,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -150049,9 +150640,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -150061,10 +150652,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -150099,9 +150690,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -150216,7 +150807,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -150256,7 +150847,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -150309,9 +150900,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -150321,7 +150912,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -150336,30 +150927,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -150376,13 +150967,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -150420,11 +151011,11 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -150451,7 +151042,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -150484,14 +151075,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -150542,7 +151133,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -150561,7 +151152,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -150613,7 +151204,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150624,14 +151215,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150648,7 +151239,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150659,7 +151250,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150686,7 +151277,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -150747,7 +151338,7 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options); + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, options); var _loop_14 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { @@ -150822,7 +151413,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -150885,7 +151476,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -150966,7 +151557,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -150975,7 +151566,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -150995,7 +151586,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -151011,10 +151602,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -151024,7 +151615,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -151129,12 +151720,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -151150,11 +151741,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -151164,7 +151755,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -151175,8 +151766,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -151278,7 +151869,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -151295,7 +151886,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -151305,7 +151896,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -151387,12 +151978,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -151413,10 +152004,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -151454,10 +152045,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -151497,9 +152088,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -151517,29 +152108,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -151586,8 +152177,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -151595,11 +152186,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -151638,19 +152229,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -151679,8 +152270,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -151695,23 +152286,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -151719,10 +152310,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -151742,7 +152333,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -151757,7 +152348,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -151768,7 +152359,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -151779,10 +152370,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -151839,7 +152430,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -151861,11 +152452,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -151889,7 +152480,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -151919,7 +152510,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -151979,7 +152570,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -152148,7 +152739,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -152161,10 +152752,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -152260,7 +152851,7 @@ var ts; var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider); var useRequire = shouldUseRequire(sourceFile, program); - var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); + var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); if (fix) { addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined }); } @@ -152270,20 +152861,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -152296,32 +152887,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -152349,13 +152940,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -152365,7 +152956,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -152430,7 +153021,7 @@ var ts; : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences)); + var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences)); return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, @@ -152443,13 +153034,13 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; - function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host); + return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; @@ -152471,7 +153062,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -152494,7 +153085,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -152504,25 +153095,32 @@ var ts; return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); } } - function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { - var _a = getNewImportFixes(program, importingFile, - /*position*/ undefined, - /*isValidTypeOnlyUseSite*/ false, - /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; + function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { + var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, + /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host); return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount }); } codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; - function getImportFixes(exportInfos, symbolName, + function getImportFixes(exportInfos, useNamespaceInfo, /** undefined only for missing JSX namespace */ - position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) { + isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) { var checker = program.getTypeChecker(); var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); - var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); + var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker); var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions()); - // 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, position, isValidTypeOnlyUseSite, useRequire, host, preferences); - return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true); + if (addToExisting) { + // Don't bother providing an action to add a new import if we can add to an existing one. + return { + computedWithoutCacheCount: 0, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false), + }; + } + var _a = getFixesForAddImport(exportInfos, existingImports, program, sourceFile, useNamespaceInfo === null || useNamespaceInfo === void 0 ? void 0 : useNamespaceInfo.position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly), fixes = _a.fixes, _b = _a.computedWithoutCacheCount, computedWithoutCacheCount = _b === void 0 ? 0 : _b; + return { + computedWithoutCacheCount: computedWithoutCacheCount, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true), + }; } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -152538,13 +153136,14 @@ var ts; // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. return ts.firstDefined(existingImports, function (_a) { + var _b; var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -152552,11 +153151,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -152566,11 +153165,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -152579,31 +153178,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -152612,22 +153211,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -152638,7 +153237,7 @@ var ts; function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { @@ -152646,7 +153245,7 @@ var ts; if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } - if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } }); @@ -152684,6 +153283,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); }); + var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions)); var getModuleSpecifiers = fromCacheOnly ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); } : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); }; @@ -152691,38 +153291,39 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; - return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) { - // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return !importedSymbolHasValueMeaning && isJs && position !== undefined - ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } - : { - kind: 3 /* AddNew */, - moduleSpecifier: moduleSpecifier, - importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), - useRequire: useRequire, - addAsTypeOnly: addAsTypeOnly, - exportInfo: exportInfo, - isReExport: i > 0, - }; + return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { + return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : + // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + { + kind: 3 /* ImportFixKind.AddNew */, + moduleSpecifier: moduleSpecifier, + importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), + useRequire: useRequire, + addAsTypeOnly: addAsTypeOnly, + exportInfo: exportInfo, + isReExport: i > 0, + }; }); }); return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes }; } - function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); }); - return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes; + return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly); } function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) { + var _b; var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -152753,23 +153354,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -152792,10 +153393,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -152806,9 +153407,10 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences); + var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; + var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text }; } function getUmdSymbol(token, checker) { @@ -152819,7 +153421,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -152828,10 +153430,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -152839,7 +153441,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -152848,9 +153450,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -152858,12 +153460,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; - case ts.ModuleKind.Node12: + return 2 /* ImportKind.Namespace */; + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -152872,7 +153474,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -152880,19 +153482,19 @@ var ts; var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes; })); return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text }; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -152907,8 +153509,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -152940,7 +153542,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -152951,14 +153553,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -152967,12 +153569,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -152983,45 +153585,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -153029,7 +153631,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -153047,13 +153649,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -153065,7 +153667,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -153075,7 +153677,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -153084,7 +153686,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -153094,7 +153696,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -153145,7 +153747,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -153169,11 +153771,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -153182,12 +153784,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) @@ -153228,7 +153830,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -153265,7 +153867,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -153399,7 +154001,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -153407,19 +154009,19 @@ var ts; changeTracker.filterJSDocTags(sourceFile, classElement, ts.not(ts.isJSDocOverrideTag)); return; } - var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* OverrideKeyword */; }); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* SyntaxKind.OverrideKeyword */; }); ts.Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -153461,7 +154063,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -153501,7 +154103,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -153520,7 +154122,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -153551,7 +154153,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -153560,16 +154162,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -153635,18 +154237,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -153664,7 +154266,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -153697,14 +154299,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -153776,7 +154378,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -153835,7 +154437,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -153879,19 +154481,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -153953,19 +154555,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -153983,20 +154585,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -154020,15 +154622,15 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; @@ -154055,12 +154657,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -154069,7 +154671,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -154077,17 +154679,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -154099,13 +154701,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -154119,15 +154721,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -154143,18 +154745,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -154191,32 +154793,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -154244,7 +154846,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -154269,15 +154871,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -154297,7 +154899,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.decorators, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -154307,7 +154909,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } function addJsxAttributes(changes, context, info) { @@ -154335,7 +154937,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop)); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* QuotePreference.Single */), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -154345,42 +154947,42 @@ var ts; changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -154394,17 +154996,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -154419,8 +155021,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -154444,7 +155046,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -154529,7 +155131,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -154604,7 +155206,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -154647,7 +155249,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -154772,8 +155374,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { var compilerOptions = context.program.getCompilerOptions(); @@ -154791,7 +155393,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -154870,17 +155472,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -154977,7 +155579,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -155084,7 +155686,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -155099,7 +155701,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -155111,11 +155713,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -155123,7 +155725,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -155132,7 +155734,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -155168,7 +155770,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -155210,7 +155812,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -155252,13 +155854,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -155281,7 +155883,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -155292,7 +155894,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -155301,18 +155903,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -155321,15 +155923,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -155337,14 +155939,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -155394,8 +155996,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -155404,7 +156006,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -155425,20 +156027,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -155499,7 +156101,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -155510,8 +156112,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -155560,7 +156162,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -155584,10 +156186,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -155604,7 +156206,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -155621,22 +156223,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -155671,7 +156273,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -155739,15 +156341,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -155762,11 +156364,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -155928,7 +156530,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -156029,9 +156631,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -156039,7 +156641,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -156082,7 +156684,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -156118,7 +156720,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -156126,9 +156728,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -156137,7 +156739,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -156151,7 +156753,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -156169,19 +156771,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -156323,24 +156925,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -156348,20 +156950,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -156385,13 +156987,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -156401,65 +157003,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -156467,31 +157069,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -156511,7 +157113,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -156536,7 +157138,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -156583,21 +157185,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -156616,22 +157218,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -156663,7 +157265,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -156680,7 +157282,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -156708,7 +157310,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -156722,7 +157324,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -156741,10 +157343,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -156758,8 +157360,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -156795,10 +157397,10 @@ var ts; var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); var _loop_16 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; @@ -156806,15 +157408,15 @@ var ts; _loop_16(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -156898,7 +157500,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -156965,7 +157567,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -156978,13 +157580,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -156994,11 +157596,11 @@ var ts; } } addClassElement(ts.factory.createPropertyDeclaration( - /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -157027,8 +157629,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -157036,7 +157638,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!ts.some(signatures)) { break; } @@ -157058,13 +157660,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -157074,11 +157676,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 1073741824 /* NoUndefinedOptionalParameterType */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -157131,7 +157732,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -157163,26 +157764,26 @@ var ts; ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; var typeParameters = isJs || typeArguments === undefined ? undefined : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); + return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* CharacterCodes.T */ + typeArguments.length - 1 <= 90 /* CharacterCodes.Z */ ? String.fromCharCode(84 /* CharacterCodes.T */ + i) : "T".concat(i)); }); var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, /*questionToken*/ undefined, typeParameters, parameters, type); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: @@ -157210,9 +157811,9 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ names && names[i] || "arg".concat(i), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -157242,8 +157843,8 @@ var ts; if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -157259,7 +157860,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -157268,16 +157869,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -157350,7 +157951,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -157423,17 +158024,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -157442,7 +158043,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -157460,13 +158061,13 @@ var ts; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -157522,13 +158123,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -157543,7 +158144,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -157555,7 +158156,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -157602,7 +158203,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -157720,7 +158321,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -157728,7 +158329,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -157757,7 +158358,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -157766,7 +158367,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -157774,7 +158375,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -157950,8 +158551,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -158014,7 +158615,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -158080,7 +158681,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -158138,7 +158739,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -158149,7 +158750,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -158221,7 +158822,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -158258,14 +158859,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -158278,6 +158879,7 @@ var ts; var fixName = "addVoidToPromise"; var fixId = "addVoidToPromise"; var errorCodes = [ + ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code, ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code ]; codefix.registerCodeFix({ @@ -158312,7 +158914,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -158324,14 +158926,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -158407,15 +159009,15 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var checker = program.getTypeChecker(); @@ -158424,22 +159026,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -158449,7 +159051,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -158473,18 +159075,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -158493,15 +159095,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -158522,18 +159124,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -158542,10 +159144,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -158556,7 +159158,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -158567,11 +159169,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -158584,7 +159186,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -158593,7 +159195,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -158612,17 +159214,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -158674,13 +159276,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -158688,11 +159290,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -158705,7 +159307,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -158754,14 +159356,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -158910,7 +159512,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -158926,7 +159528,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -159052,17 +159654,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -159077,7 +159679,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -159123,27 +159725,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -159165,24 +159767,24 @@ var ts; return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -159195,12 +159797,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -159326,7 +159928,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -159334,7 +159936,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -159350,7 +159952,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -159358,7 +159960,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -159454,6 +160056,7 @@ var ts; Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block"); + Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method"); })(Messages = extractSymbol.Messages || (extractSymbol.Messages = {})); var RangeFacts; (function (RangeFacts) { @@ -159462,10 +160065,11 @@ var ts; RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction"; /** * The range is in a function which needs the 'static' modifier in a class */ - RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion"; })(RangeFacts || (RangeFacts = {})); /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array @@ -159496,11 +160100,12 @@ var ts; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. var rangeFacts = RangeFacts.None; + var thisNode; if (!start || !end) { // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -159534,7 +160139,7 @@ var ts; // the expression. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. @@ -159546,7 +160151,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -159589,20 +160194,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -159626,7 +160231,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -159635,9 +160240,17 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); + if (rangeFacts & RangeFacts.UsesThis) { + var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { + rangeFacts |= RangeFacts.UsesThisInFunction; + } + } return errors; function visit(node) { if (errors) { @@ -159645,8 +160258,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -159657,16 +160270,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -159676,13 +160289,15 @@ var ts; } else { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) { return false; @@ -159692,63 +160307,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps = 0 /* PermittedJumps.None */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; + thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -159757,21 +160373,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -159794,7 +160410,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -159826,7 +160442,7 @@ var ts; */ function collectEnclosingScopes(range) { var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range; - if (range.facts & RangeFacts.UsesThis) { + if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class var containingClass = ts.getContainingClass(current); if (containingClass) { @@ -159840,7 +160456,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -159851,7 +160467,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -159891,11 +160507,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -159941,34 +160557,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -159999,7 +160615,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -160008,7 +160624,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -160027,27 +160643,37 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); var newFunction; + var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { + if (callThis) { + parameters.unshift(ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ "this", + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), + /*initializer*/ undefined)); + } newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -160062,10 +160688,13 @@ var ts; var newNodes = []; // replace range with function call var called = getCalledExpression(scope, range, functionNameText); - var call = ts.factory.createCallExpression(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference + if (callThis) { + callArguments.unshift(ts.factory.createIdentifier("this")); + } + var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -160099,7 +160728,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -160110,7 +160739,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -160125,8 +160754,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -160135,7 +160764,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -160192,9 +160821,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -160207,13 +160836,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -160221,11 +160850,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -160257,16 +160886,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -160276,7 +160905,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -160303,7 +160932,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -160322,7 +160951,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -160332,7 +160961,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -160345,10 +160974,10 @@ var ts; /* decorators */ undefined, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -160595,7 +161224,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -160673,14 +161302,17 @@ var ts; var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes)); } + if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) { + functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod)); + } var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -160724,7 +161356,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -160734,11 +161366,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -160812,7 +161444,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -160839,7 +161471,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -160920,30 +161552,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -161089,7 +161721,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -161120,7 +161752,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -161132,7 +161764,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -161158,7 +161790,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -161342,11 +161974,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -161386,7 +162018,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -161442,25 +162074,25 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -161478,21 +162110,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -161518,7 +162150,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -161542,7 +162174,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -161562,19 +162194,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -161583,7 +162215,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -161595,7 +162227,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -161608,14 +162240,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -161657,7 +162289,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -161674,7 +162306,7 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } function getNewModuleName(movedSymbols) { @@ -161684,7 +162316,7 @@ var ts; var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -161718,7 +162350,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -161736,7 +162368,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -161745,14 +162377,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -161764,7 +162396,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -161774,18 +162406,18 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -161795,11 +162427,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -161856,13 +162488,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -161870,19 +162502,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -161890,13 +162522,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -161904,9 +162536,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -161928,7 +162560,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -161936,28 +162568,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], d.modifiers); switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -161965,26 +162597,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -162047,14 +162679,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -162188,7 +162820,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -162287,7 +162919,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -162317,15 +162949,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -162335,7 +162967,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -162354,14 +162986,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -162373,7 +163005,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -162407,16 +163039,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -162424,8 +163056,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -162435,7 +163067,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -162541,7 +163173,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -162550,7 +163182,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -162575,15 +163207,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -162594,30 +163226,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -162698,16 +163330,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -162725,7 +163357,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -162738,7 +163370,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -162747,7 +163379,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -162839,8 +163471,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -163035,7 +163667,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -163061,7 +163693,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -163121,13 +163753,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -163137,7 +163769,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -163148,17 +163780,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -163185,20 +163817,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -163260,8 +163892,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -163272,7 +163904,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -163320,19 +163952,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -163349,9 +163981,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -163391,7 +164023,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -163443,12 +164075,12 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -163465,12 +164097,12 @@ var ts; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -163494,7 +164126,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -163506,7 +164138,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -163521,7 +164153,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -163543,16 +164175,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -163573,41 +164205,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -163671,7 +164303,7 @@ var ts; var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -163698,7 +164330,7 @@ var ts; var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -163719,7 +164351,7 @@ var ts; var _a; if (ts.hasStaticModifier(declaration)) return; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) { @@ -163731,7 +164363,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -163790,10 +164422,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -163813,31 +164445,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -163848,12 +164480,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -163866,7 +164498,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -163878,7 +164510,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -163887,8 +164519,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -163957,8 +164589,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -163977,7 +164609,7 @@ var ts; this.fileNameToEntry = new ts.Map(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "initializeHostCache", { count: rootFileNames.length }); for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); @@ -164047,7 +164679,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -164144,7 +164776,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -164174,7 +164806,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -164264,7 +164896,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -164384,7 +165016,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -164574,8 +165206,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -164608,27 +165240,27 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; } } /// Goto definition - function getDefinitionAtPosition(fileName, position) { + function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly, stopAtAlias) { synchronizeHostData(); - return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); + return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias); } function getDefinitionAndBoundSpan(fileName, position) { synchronizeHostData(); @@ -164645,7 +165277,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -164669,17 +165301,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -164726,16 +165358,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -164751,7 +165383,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -164781,8 +165413,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -164791,8 +165423,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -164813,10 +165445,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -164913,7 +165545,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -164922,15 +165554,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -164940,12 +165572,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -165042,14 +165674,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -165059,7 +165691,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -165145,10 +165777,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -165163,12 +165795,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -165286,9 +165918,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -165444,14 +166076,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -165498,7 +166130,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -165513,16 +166145,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -165564,7 +166196,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -165611,7 +166243,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -165644,144 +166276,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.decorators); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -165793,14 +166425,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -165809,35 +166441,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -165846,21 +166478,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -165868,7 +166500,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -165898,7 +166530,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -165909,8 +166541,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if (variableDeclaration.initializer || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -165925,7 +166557,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -165950,8 +166582,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -165974,26 +166606,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -166018,21 +166650,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -166040,18 +166672,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -166059,25 +166691,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -166085,7 +166717,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -166101,7 +166733,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -166116,12 +166748,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -166130,21 +166762,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -166154,20 +166786,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -166175,7 +166807,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -166343,7 +166975,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -166433,13 +167065,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -166521,7 +167153,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -166537,43 +167169,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -166589,7 +167221,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -166598,7 +167230,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -166606,12 +167238,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -166620,7 +167252,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -166628,7 +167260,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -166637,7 +167269,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -166646,37 +167278,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, options); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -166684,23 +167316,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -166715,108 +167347,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -166866,11 +167498,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -166881,7 +167513,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -166893,7 +167525,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -166908,7 +167540,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -166930,7 +167562,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -167120,7 +167752,7 @@ var ts; } Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + throw new Error("Project '".concat(project.getProjectName(), "' does not contain document '").concat(fileName, "'")); } Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; })(Errors = server.Errors || (server.Errors = {})); @@ -167161,14 +167793,19 @@ var ts; } server.isInferredProjectName = isInferredProjectName; function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; + return "/dev/null/inferredProject".concat(counter, "*"); } server.makeInferredProjectName = makeInferredProjectName; /*@internal*/ function makeAutoImportProviderProjectName(counter) { - return "/dev/null/autoImportProviderProject" + counter + "*"; + return "/dev/null/autoImportProviderProject".concat(counter, "*"); } server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName; + /*@internal*/ + function makeAuxiliaryProjectName(counter) { + return "/dev/null/auxiliaryProject".concat(counter, "*"); + } + server.makeAuxiliaryProjectName = makeAuxiliaryProjectName; function createSortedArray() { return []; // TODO: GH#19873 } @@ -167201,7 +167838,7 @@ var ts; // schedule new operation, pass arguments this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); if (this.logger) { - this.logger.info("Scheduled: " + operationId + (pendingTimeout ? ", Cancelled earlier one" : "")); + this.logger.info("Scheduled: ".concat(operationId).concat(pendingTimeout ? ", Cancelled earlier one" : "")); } }; ThrottledOperations.prototype.cancel = function (operationId) { @@ -167215,7 +167852,7 @@ var ts; ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { - self.logger.info("Running: " + operationId); + self.logger.info("Running: ".concat(operationId)); } cb(); ts.perfLogger.logStopScheduledOperation(); @@ -167244,7 +167881,7 @@ var ts; self.host.gc(); // TODO: GH#18217 if (log) { var after = self.host.getMemoryUsage(); // TODO: GH#18217 - self.logger.perftrc("GC::before " + before + ", after " + after); + self.logger.perftrc("GC::before ".concat(before, ", after ").concat(after)); } ts.perfLogger.logStopScheduledOperation(); }; @@ -167382,6 +168019,7 @@ var ts; CommandTypes["SignatureHelp"] = "signatureHelp"; /* @internal */ CommandTypes["SignatureHelpFull"] = "signatureHelp-full"; + CommandTypes["FindSourceDefinition"] = "findSourceDefinition"; CommandTypes["Status"] = "status"; CommandTypes["TypeDefinition"] = "typeDefinition"; CommandTypes["ProjectInfo"] = "projectInfo"; @@ -167597,8 +168235,8 @@ var ts; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.version.svc + "-" + this.svc.getSnapshotVersion() - : "Text-" + this.version.text; + ? "SVC-".concat(this.version.svc, "-").concat(this.svc.getSnapshotVersion()) + : "Text-".concat(this.version.text); }; TextStorage.prototype.hasScriptVersionCache_TestOnly = function () { return this.svc !== undefined; @@ -167741,7 +168379,7 @@ var ts; if (fileSize > server.maxFileSize) { ts.Debug.assert(!!this.info.containingProjects.length); var service = this.info.containingProjects[0].projectService; - service.logger.info("Skipped loading contents of large file " + fileName + " for info " + this.info.fileName + ": fileSize: " + fileSize); + service.logger.info("Skipped loading contents of large file ".concat(fileName, " for info ").concat(this.info.fileName, ": fileSize: ").concat(fileSize)); this.info.containingProjects[0].projectService.sendLargeFileReferencedEvent(fileName, fileSize); return { text: "", fileSize: fileSize }; } @@ -167961,7 +168599,7 @@ var ts; case 0: return server.Errors.ThrowNoProject(); case 1: - return ensureNotAutoImportProvider(this.containingProjects[0]); + return ensurePrimaryProjectKind(this.containingProjects[0]); default: // If this file belongs to multiple projects, below is the order in which default project is used // - for open script info, its default configured project during opening is default if info is part of it @@ -167999,7 +168637,7 @@ var ts; firstInferredProject = project; } } - return ensureNotAutoImportProvider(defaultConfiguredProject || + return ensurePrimaryProjectKind(defaultConfiguredProject || firstNonSourceOfProjectReferenceRedirect || firstConfiguredProject || firstExternalProject || @@ -168075,8 +168713,8 @@ var ts; return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); }); }; /*@internal*/ - ScriptInfo.prototype.isContainedByAutoImportProvider = function () { - return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; }); + ScriptInfo.prototype.isContainedByBackgroundProject = function () { + return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; }); }; /** * @param line 1 based index @@ -168094,7 +168732,7 @@ var ts; return location; }; ScriptInfo.prototype.isJavaScript = function () { - return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */; + return this.scriptKind === 1 /* ScriptKind.JS */ || this.scriptKind === 2 /* ScriptKind.JSX */; }; /*@internal*/ ScriptInfo.prototype.getLineInfo = function () { @@ -168110,21 +168748,26 @@ var ts; return ScriptInfo; }()); server.ScriptInfo = ScriptInfo; - function ensureNotAutoImportProvider(project) { - if (!project || project.projectKind === server.ProjectKind.AutoImportProvider) { + /** + * Throws an error if `project` is an AutoImportProvider or AuxiliaryProject, + * which are used in the background by other Projects and should never be + * reported as the default project for a ScriptInfo. + */ + function ensurePrimaryProjectKind(project) { + if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) { return server.Errors.ThrowNoProject(); } return project; } function failIfInvalidPosition(position) { - ts.Debug.assert(typeof position === "number", "Expected position " + position + " to be a number."); + ts.Debug.assert(typeof position === "number", "Expected position ".concat(position, " to be a number.")); ts.Debug.assert(position >= 0, "Expected position to be non-negative."); } function failIfInvalidLocation(location) { - ts.Debug.assert(typeof location.line === "number", "Expected line " + location.line + " to be a number."); - ts.Debug.assert(typeof location.offset === "number", "Expected offset " + location.offset + " to be a number."); - ts.Debug.assert(location.line > 0, "Expected line to be non-" + (location.line === 0 ? "zero" : "negative")); - ts.Debug.assert(location.offset > 0, "Expected offset to be non-" + (location.offset === 0 ? "zero" : "negative")); + ts.Debug.assert(typeof location.line === "number", "Expected line ".concat(location.line, " to be a number.")); + ts.Debug.assert(typeof location.offset === "number", "Expected offset ".concat(location.offset, " to be a number.")); + ts.Debug.assert(location.line > 0, "Expected line to be non-".concat(location.line === 0 ? "zero" : "negative")); + ts.Debug.assert(location.offset > 0, "Expected offset to be non-".concat(location.offset === 0 ? "zero" : "negative")); } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -168251,6 +168894,7 @@ var ts; ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; ProjectKind[ProjectKind["External"] = 2] = "External"; ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider"; + ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary"; })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); /* @internal */ function countEachFileTypes(infos, includeSizes) { @@ -168267,16 +168911,16 @@ var ts; var info = infos_1[_i]; var fileSize = includeSizes ? info.getTelemetryFileSize() : 0; switch (info.scriptKind) { - case 1 /* JS */: + case 1 /* ScriptKind.JS */: result.js += 1; result.jsSize += fileSize; break; - case 2 /* JSX */: + case 2 /* ScriptKind.JSX */: result.jsx += 1; result.jsxSize += fileSize; break; - case 3 /* TS */: - if (ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */)) { + case 3 /* ScriptKind.TS */: + if (ts.isDeclarationFileName(info.fileName)) { result.dts += 1; result.dtsSize += fileSize; } @@ -168285,11 +168929,11 @@ var ts; result.tsSize += fileSize; } break; - case 4 /* TSX */: + case 4 /* ScriptKind.TSX */: result.tsx += 1; result.tsxSize += fileSize; break; - case 7 /* Deferred */: + case 7 /* ScriptKind.Deferred */: result.deferred += 1; result.deferredSize += fileSize; break; @@ -168314,7 +168958,7 @@ var ts; server.allFilesAreJsOrDts = allFilesAreJsOrDts; /* @internal */ function hasNoTypeScriptSource(fileNames) { - return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); }); + return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Extension.Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Extension.Tsx */); }); } server.hasNoTypeScriptSource = hasNoTypeScriptSource; function isGeneratedFileWatcher(watch) { @@ -168436,11 +169080,11 @@ var ts; }; Project.resolveModule = function (moduleName, initialDir, host, log, logErrors) { var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); - log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + log("Loading ".concat(moduleName, " from ").concat(initialDir, " (resolved to ").concat(resolvedPath, ")")); var result = host.require(resolvedPath, moduleName); // TODO: GH#18217 if (result.error) { var err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)("Failed to load module '" + moduleName + "' from " + resolvedPath + ": " + err); + (logErrors || log)("Failed to load module '".concat(moduleName, "' from ").concat(resolvedPath, ": ").concat(err)); return undefined; } return result.module; @@ -168591,12 +169235,12 @@ var ts; }; /*@internal*/ Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () { - return this.projectService.throttledOperations.cancel(this.getProjectName() + "FailedLookupInvalidation"); + return this.projectService.throttledOperations.cancel("".concat(this.getProjectName(), "FailedLookupInvalidation")); }; /*@internal*/ Project.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { var _this = this; - this.projectService.throttledOperations.schedule(this.getProjectName() + "FailedLookupInvalidation", /*delay*/ 1000, function () { + this.projectService.throttledOperations.schedule("".concat(this.getProjectName(), "FailedLookupInvalidation"), /*delay*/ 1000, function () { if (_this.resolutionCache.invalidateResolutionsOfFailedLookupLocations()) { _this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(_this); } @@ -168718,7 +169362,7 @@ var ts; } // Update the signature if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) { - var dtsFiles = outputFiles.filter(function (f) { return ts.fileExtensionIs(f.name, ".d.ts" /* Dts */); }); + var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); }); if (dtsFiles.length === 1) { var sourceFile = this.program.getSourceFile(scriptInfo.fileName); var signature = this.projectService.host.createHash ? @@ -168774,7 +169418,7 @@ var ts; return plugin.module.getExternalFiles(_this); } catch (e) { - _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: ".concat(e)); if (e.stack) { _this.projectService.logger.info(e.stack); } @@ -168837,6 +169481,10 @@ var ts; this.autoImportProviderHost.close(); } this.autoImportProviderHost = undefined; + if (this.noDtsResolutionProject) { + this.noDtsResolutionProject.close(); + } + this.noDtsResolutionProject = undefined; // signal language service to release source files acquired from document registry this.languageService.dispose(); this.languageService = undefined; @@ -168877,7 +169525,7 @@ var ts; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.resolvedPath); - ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' / '" + sourceFile.resolvedPath + "' is missing."; }); + ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '".concat(sourceFile.fileName, "' Path: '").concat(sourceFile.path, "' / '").concat(sourceFile.resolvedPath, "' is missing."); }); return scriptInfo; }); }; @@ -169051,7 +169699,7 @@ var ts; */ Project.prototype.updateGraph = function () { var _a; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); @@ -169122,13 +169770,13 @@ var ts; var _this = this; var oldProgram = this.program; ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project"); - this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName()); + this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName())); var start = ts.timestamp(); this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution"); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "finishCachingPerDirectoryResolution"); this.resolutionCache.finishCachingPerDirectoryResolution(); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); ts.Debug.assert(oldProgram === undefined || this.program !== undefined); @@ -169136,7 +169784,7 @@ var ts; // - oldProgram is not set - this is a first time updateGraph is called // - newProgram is different from the old program and structure of the old program was not reused. var hasNewProgram = false; - if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) { + if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* StructureIsReused.Completely */))) { hasNewProgram = true; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { @@ -169162,7 +169810,7 @@ var ts; var outPath = ts.outFile(this.compilerOptions); if (isGeneratedFileWatcher(this.generatedFilesMap)) { // --out - if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Dts */, this.generatedFilesMap)) { + if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */, this.generatedFilesMap)) { this.clearGeneratedFileWatch(); } } @@ -169226,7 +169874,7 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.sendPerformanceEvent("UpdateGraph", elapsed); - this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + (this.program ? " structureIsReused:: " + ts.StructureIsReused[this.program.structureIsReused] : "") + " Elapsed: " + elapsed + "ms"); + this.writeLog("Finishing updateGraphWorker: Project: ".concat(this.getProjectName(), " Version: ").concat(this.getProjectVersion(), " structureChanged: ").concat(hasNewProgram).concat(this.program ? " structureIsReused:: ".concat(ts.StructureIsReused[this.program.structureIsReused]) : "", " Elapsed: ").concat(elapsed, "ms")); if (this.hasAddedorRemovedFiles) { this.print(/*writeProjectFileNames*/ true); } @@ -169286,7 +169934,7 @@ var ts; var path = this.toPath(sourceFile); if (this.generatedFilesMap) { if (isGeneratedFileWatcher(this.generatedFilesMap)) { - ts.Debug.fail(this.projectName + " Expected to not have --out watcher for generated file with options: " + JSON.stringify(this.compilerOptions)); + ts.Debug.fail("".concat(this.projectName, " Expected to not have --out watcher for generated file with options: ").concat(JSON.stringify(this.compilerOptions))); return; } if (this.generatedFilesMap.has(path)) @@ -169338,20 +169986,20 @@ var ts; if (!this.program) return "\tFiles (0) NoProgram\n"; var sourceFiles = this.program.getSourceFiles(); - var strBuilder = "\tFiles (" + sourceFiles.length + ")\n"; + var strBuilder = "\tFiles (".concat(sourceFiles.length, ")\n"); if (writeProjectFileNames) { for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var file = sourceFiles_1[_i]; - strBuilder += "\t" + file.fileName + "\n"; + strBuilder += "\t".concat(file.fileName, "\n"); } strBuilder += "\n\n"; - ts.explainFiles(this.program, function (s) { return strBuilder += "\t" + s + "\n"; }); + ts.explainFiles(this.program, function (s) { return strBuilder += "\t".concat(s, "\n"); }); } return strBuilder; }; /*@internal*/ Project.prototype.print = function (writeProjectFileNames) { - this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ")"); + this.writeLog("Project '".concat(this.projectName, "' (").concat(ProjectKind[this.projectKind], ")")); this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(server.LogLevel.verbose))); this.writeLog("-----------------------------------------------"); if (this.autoImportProviderHost) { @@ -169359,11 +170007,13 @@ var ts; } }; Project.prototype.setCompilerOptions = function (compilerOptions) { + var _a; if (compilerOptions) { compilerOptions.allowNonTsExtensions = true; var oldOptions = this.compilerOptions; this.compilerOptions = compilerOptions; this.setInternalCompilerOptionsForEmittingJsFiles(); + (_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject()); if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) { // reset cached unresolved imports if changes in compiler options affected module resolution this.cachedUnresolvedImportsPerFile.clear(); @@ -169513,7 +170163,7 @@ var ts; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; // Provide global: true so plugins can detect why they can't find their config - this_1.projectService.logger.info("Loading global plugin " + globalPluginName); + this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName)); this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; @@ -169526,9 +170176,9 @@ var ts; }; Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; - this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); + this.projectService.logger.info("Enabling plugin ".concat(pluginConfigEntry.name, " from candidate paths: ").concat(searchPaths.join(","))); if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) { - this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name"); + this.projectService.logger.info("Skipped loading plugin ".concat(pluginConfigEntry.name || JSON.stringify(pluginConfigEntry), " because only package name is allowed plugin name")); return; } var log = function (message) { return _this.projectService.logger.info(message); }; @@ -169551,13 +170201,13 @@ var ts; } else { ts.forEach(errorLogs, log); - this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); + this.projectService.logger.info("Couldn't find ".concat(pluginConfigEntry.name)); } }; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin ".concat(configEntry.name, " because it did not expose a proper factory function")); return; } var info = { @@ -169574,7 +170224,7 @@ var ts; var k = _a[_i]; // eslint-disable-next-line no-in-operator if (!(k in newLS)) { - this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); + this.projectService.logger.info("Plugin activation warning: Missing proxied method ".concat(k, " in created LS. Patching.")); newLS[k] = this.languageService[k]; } } @@ -169583,7 +170233,7 @@ var ts; this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { - this.projectService.logger.info("Plugin activation failed: " + e); + this.projectService.logger.info("Plugin activation failed: ".concat(e)); } }; /*@internal*/ @@ -169633,11 +170283,11 @@ var ts; }; /*@internal*/ Project.prototype.includePackageJsonAutoImports = function () { - if (this.projectService.includePackageJsonAutoImports() === 0 /* Off */ || + if (this.projectService.includePackageJsonAutoImports() === 0 /* PackageJsonAutoImportPreference.Off */ || !this.languageServiceEnabled || ts.isInsideNodeModules(this.currentDirectory) || !this.isDefaultProjectForOpenFiles()) { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; } return this.projectService.includePackageJsonAutoImports(); }; @@ -169678,7 +170328,7 @@ var ts; } var dependencySelection = this.includePackageJsonAutoImports(); if (dependencySelection) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider"); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getPackageJsonAutoImportProvider"); var start = ts.timestamp(); this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry); if (this.autoImportProviderHost) { @@ -169703,12 +170353,37 @@ var ts; Project.prototype.getIncompleteCompletionsCache = function () { return this.projectService.getIncompleteCompletionsCache(); }; + /*@internal*/ + Project.prototype.getNoDtsResolutionProject = function (rootFileNames) { + var _this = this; + ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic); + if (!this.noDtsResolutionProject) { + this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject()); + } + ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) { + var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost); + if (info) { + _this.noDtsResolutionProject.addRoot(info, pathToAdd); + } + }, function (pathToRemove) { + // It may be preferable to remove roots only once project grows to a certain size? + var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove); + if (info) { + _this.noDtsResolutionProject.removeRoot(info); + } + }); + return this.noDtsResolutionProject; + }; + /*@internal*/ + Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () { + return __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true }); + }; return Project; }()); server.Project = Project; function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) { var sourceFiles = program.getSourceFiles(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getUnresolvedImports", { count: sourceFiles.length }); var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) { return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile); @@ -169818,6 +170493,26 @@ var ts; return InferredProject; }(Project)); server.InferredProject = InferredProject; + var AuxiliaryProject = /** @class */ (function (_super) { + __extends(AuxiliaryProject, _super); + function AuxiliaryProject(projectService, documentRegistry, compilerOptions) { + return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry, + /*hasExplicitListOfFiles*/ false, + /*lastFileExceededProgramSize*/ undefined, compilerOptions, + /*compileOnSaveEnabled*/ false, + /*watchOptions*/ undefined, projectService.host, + /*currentDirectory*/ undefined) || this; + } + AuxiliaryProject.prototype.isOrphan = function () { + return true; + }; + /*@internal*/ + AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { + // Invalidation will happen on-demand as part of updateGraph + return; + }; + return AuxiliaryProject; + }(Project)); var AutoImportProviderProject = /** @class */ (function (_super) { __extends(AutoImportProviderProject, _super); /*@internal*/ @@ -169857,8 +170552,8 @@ var ts; var symlinkCache_1 = hostProject.getSymlinkCache(); var _loop_2 = function (name) { // Avoid creating a large project that would significantly slow down time to editor interactivity - if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this_2.maxDependencies) { - hostProject.log("AutoImportProviderProject: attempted to add more than " + this_2.maxDependencies + " dependencies. Aborting."); + if (dependencySelection === 2 /* PackageJsonAutoImportPreference.Auto */ && dependenciesAdded > this_2.maxDependencies) { + hostProject.log("AutoImportProviderProject: attempted to add more than ".concat(this_2.maxDependencies, " dependencies. Aborting.")); return { value: ts.emptyArray }; } // 1. Try to load from the implementation package. For many dependencies, the @@ -169878,7 +170573,7 @@ var ts; // typings cache location, if enabled. var done = ts.forEach([hostProject.currentDirectory, hostProject.getGlobalTypingsCacheLocation()], function (directory) { if (directory) { - var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); + var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/".concat(name), directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); if (typesPackageJson) { var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache_1); rootNames = ts.concatenate(rootNames, entrypoints); @@ -169907,7 +170602,7 @@ var ts; } } if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) { - hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms"); + hostProject.log("AutoImportProviderProject: found ".concat(rootNames.length, " root files in ").concat(dependenciesAdded, " dependencies in ").concat(ts.timestamp() - start, " ms")); } return rootNames || ts.emptyArray; function addDependency(dependency) { @@ -169938,7 +170633,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) { - if (dependencySelection === 0 /* Off */) { + if (dependencySelection === 0 /* PackageJsonAutoImportPreference.Off */) { return undefined; } var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), this.compilerOptionsOverrides); @@ -169969,6 +170664,11 @@ var ts; } return hasSameSetOfFiles; }; + /*@internal*/ + AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { + // Invalidation will happen on-demand as part of updateGraph + return; + }; AutoImportProviderProject.prototype.hasRoots = function () { var _a; return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length); @@ -169999,7 +170699,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.prototype.includePackageJsonAutoImports = function () { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; }; AutoImportProviderProject.prototype.getTypeAcquisition = function () { return { enable: false }; @@ -170164,7 +170864,7 @@ var ts; var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); - this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); + this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths")); searchPaths.unshift(local); } // Enable tsconfig-specified plugins @@ -170443,15 +171143,15 @@ var ts; function convertScriptKindName(scriptKindName) { switch (scriptKindName) { case "JS": - return 1 /* JS */; + return 1 /* ScriptKind.JS */; case "JSX": - return 2 /* JSX */; + return 2 /* ScriptKind.JSX */; case "TS": - return 3 /* TS */; + return 3 /* ScriptKind.TS */; case "TSX": - return 4 /* TSX */; + return 4 /* ScriptKind.TSX */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } server.convertScriptKindName = convertScriptKindName; @@ -170590,7 +171290,7 @@ var ts; return forEachAnyProjectReferenceKind(project, function (resolvedRef) { return callbackRefProject(project, cb, resolvedRef.sourceFile.path); }, function (projectRef) { return callbackRefProject(project, cb, project.toPath(ts.resolveProjectReferencePath(projectRef))); }, function (potentialProjectRef) { return callbackRefProject(project, cb, potentialProjectRef); }); } function getDetailWatchInfo(watchType, project) { - return (ts.isString(project) ? "Config: " + project + " " : project ? "Project: " + project.getProjectName() + " " : "") + "WatchType: " + watchType; + return "".concat(ts.isString(project) ? "Config: ".concat(project, " ") : project ? "Project: ".concat(project.getProjectName(), " ") : "", "WatchType: ").concat(watchType); } function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; @@ -170654,6 +171354,8 @@ var ts; this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName); /*@internal*/ this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName); + /*@internal*/ + this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName); /** * Open files: with value being project root path, and key being Path of the file that is open */ @@ -170795,7 +171497,7 @@ var ts; try { var fileContent = this.host.readFile(this.typesMapLocation); // TODO: GH#18217 if (fileContent === undefined) { - this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); + this.logger.info("Provided types map file \"".concat(this.typesMapLocation, "\" doesn't exist")); return; } var raw = JSON.parse(fileContent); @@ -170813,7 +171515,7 @@ var ts; } } catch (e) { - this.logger.info("Error loading types map: " + e); + this.logger.info("Error loading types map: ".concat(e)); this.safelist = defaultTypeSafeList; this.legacySafelist.clear(); } @@ -170857,13 +171559,15 @@ var ts; ProjectService.prototype.delayUpdateProjectGraph = function (project) { var _this = this; project.markAsDirty(); - var projectName = project.getProjectName(); - this.pendingProjectUpdates.set(projectName, project); - this.throttledOperations.schedule(projectName, /*delay*/ 250, function () { - if (_this.pendingProjectUpdates.delete(projectName)) { - updateProjectIfDirty(project); - } - }); + if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) { + var projectName_1 = project.getProjectName(); + this.pendingProjectUpdates.set(projectName_1, project); + this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () { + if (_this.pendingProjectUpdates.delete(projectName_1)) { + updateProjectIfDirty(project); + } + }); + } }; /*@internal*/ ProjectService.prototype.hasPendingProjectUpdate = function (project) { @@ -171135,7 +171839,7 @@ var ts; var fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { - _this.logger.info("Config: " + configFileName + " Detected new package.json: " + fileOrDirectory); + _this.logger.info("Config: ".concat(configFileName, " Detected new package.json: ").concat(fileOrDirectory)); _this.onAddPackageJson(fileOrDirectoryPath); } var configuredProjectForConfig = _this.findConfiguredProjectByProjectName(configFileName); @@ -171257,14 +171961,14 @@ var ts; this.logger.info("`remove Project::"); project.print(/*writeProjectFileNames*/ true); project.close(); - if (ts.Debug.shouldAssert(1 /* Normal */)) { - this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? + if (ts.Debug.shouldAssert(1 /* AssertionLevel.Normal */)) { + this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return "".concat(project.projectName, ": ScriptInfos still attached: ").concat(JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? { fileName: info.fileName, projects: info.containingProjects.map(function (p) { return p.projectName; }), hasMixedContent: info.hasMixedContent } : undefined; })), - /*replacer*/ undefined, " "); }); }); + /*replacer*/ undefined, " ")); }); }); } // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); @@ -171665,15 +172369,15 @@ var ts; if (result !== undefined) return result || undefined; } - this.logger.info("Search path: " + ts.getDirectoryPath(info.fileName)); + this.logger.info("Search path: ".concat(ts.getDirectoryPath(info.fileName))); var configFileName = this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { return _this.configFileExists(configFileName, canonicalConfigFilePath, info); }); if (configFileName) { - this.logger.info("For info: " + info.fileName + " :: Config file name: " + configFileName); + this.logger.info("For info: ".concat(info.fileName, " :: Config file name: ").concat(configFileName)); } else { - this.logger.info("For info: " + info.fileName + " :: No config files found."); + this.logger.info("For info: ".concat(info.fileName, " :: No config files found.")); } if (isOpenScriptInfo(info)) { this.configFileForOpenFiles.set(info.path, configFileName || false); @@ -171692,8 +172396,8 @@ var ts; this.logger.info("Open files: "); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); - _this.logger.info("\tFileName: " + info.fileName + " ProjectRootPath: " + projectRootPath); - _this.logger.info("\t\tProjects: " + info.containingProjects.map(function (p) { return p.getProjectName(); })); + _this.logger.info("\tFileName: ".concat(info.fileName, " ProjectRootPath: ").concat(projectRootPath)); + _this.logger.info("\t\tProjects: ".concat(info.containingProjects.map(function (p) { return p.getProjectName(); }))); }); this.logger.endGroup(); }; @@ -171732,7 +172436,7 @@ var ts; .map(function (name) { return ({ name: name, size: _this.host.getFileSize(name) }); }) .sort(function (a, b) { return b.size - a.size; }) .slice(0, 5); - this.logger.info("Non TS file size exceeded limit (" + totalNonTsFileSize + "). Largest files: " + top5LargestFiles.map(function (file) { return file.name + ":" + file.size; }).join(", ")); + this.logger.info("Non TS file size exceeded limit (".concat(totalNonTsFileSize, "). Largest files: ").concat(top5LargestFiles.map(function (file) { return "".concat(file.name, ":").concat(file.size); }).join(", "))); // Keep the size as zero since it's disabled return fileName; } @@ -171801,8 +172505,8 @@ var ts; }; /* @internal */ ProjectService.prototype.createConfiguredProject = function (configFileName) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName }); - this.logger.info("Creating configuration project " + configFileName); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "createConfiguredProject", { configFilePath: configFileName }); + this.logger.info("Creating configuration project ".concat(configFileName)); var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); // We could be in this scenario if project is the configured project tracked by external project @@ -171850,7 +172554,7 @@ var ts; /* @internal */ ProjectService.prototype.loadConfiguredProject = function (project, reason) { var _this = this; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); this.sendProjectLoadingStartEvent(project, reason); // Read updated contents from disk var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath())); @@ -171915,12 +172619,12 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } - this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + this.logger.info("Config: ".concat(configFilename, " : ").concat(JSON.stringify({ rootNames: parsedCommandLine.fileNames, options: parsedCommandLine.options, watchOptions: parsedCommandLine.watchOptions, projectReferences: parsedCommandLine.projectReferences - }, /*replacer*/ undefined, " ")); + }, /*replacer*/ undefined, " "))); var oldCommandLine = (_b = configFileExistenceInfo.config) === null || _b === void 0 ? void 0 : _b.parsedCommandLine; if (!configFileExistenceInfo.config) { configFileExistenceInfo.config = { parsedCommandLine: parsedCommandLine, cachedDirectoryStructureHost: cachedDirectoryStructureHost, projects: new ts.Map() }; @@ -171950,7 +172654,7 @@ var ts; // Update projects var ensureProjectsForOpenFiles = false; (_a = _this.sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (canonicalPath) { - ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file " + extendedConfigFileName + " detected") || ensureProjectsForOpenFiles; + ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file ".concat(extendedConfigFileName, " detected")) || ensureProjectsForOpenFiles; }); if (ensureProjectsForOpenFiles) _this.delayEnsureProjectForOpenFiles(); @@ -172106,7 +172810,7 @@ var ts; // Clear the cache since we are reloading the project from disk host.clearCache(); var configFileName = project.getConfigFilePath(); - this.logger.info((isInitialLoad ? "Loading" : "Reloading") + " configured project " + configFileName); + this.logger.info("".concat(isInitialLoad ? "Loading" : "Reloading", " configured project ").concat(configFileName)); // Load project from the disk this.loadConfiguredProject(project, reason); project.updateGraph(); @@ -172245,7 +172949,7 @@ var ts; var path = _a[0], scriptInfo = _a[1]; return ({ path: path, fileName: scriptInfo.fileName }); }); - this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); + this.logger.msg("Could not find file ".concat(JSON.stringify(fileName), ".\nAll files are: ").concat(JSON.stringify(names)), server.Msg.Err); }; /** * Returns the projects that contain script info through SymLink @@ -172338,7 +173042,7 @@ var ts; } } } - }, 1 /* Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); + }, 1 /* WatchDirectoryFlags.Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); var result = { refreshScriptInfoRefCount: 0, affectedModuleSpecifierCacheProjects: undefined, @@ -172429,9 +173133,9 @@ var ts; var info = this.getScriptInfoForPath(path); if (!info) { var isDynamic = server.isDynamicFileName(fileName); - ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); - ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); - ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."; }); + ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"); }); + ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"); }); + ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."); }); // If the file is not opened by client and the file doesnot exist on the disk, return if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; @@ -172610,13 +173314,13 @@ var ts; var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); if (info) { info.setOptions(convertFormatOptions(args.formatOptions), args.preferences); - this.logger.info("Host configuration update for file " + args.file); + this.logger.info("Host configuration update for file ".concat(args.file)); } } else { if (args.hostInfo !== undefined) { this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); + this.logger.info("Host information ".concat(args.hostInfo)); } if (args.formatOptions) { this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); @@ -172648,7 +173352,7 @@ var ts; } if (args.watchOptions) { this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions; - this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches."); + this.logger.info("Host watch options changed to ".concat(JSON.stringify(this.hostConfiguration.watchOptions), ", it will be take effect for next watches.")); } } }; @@ -172860,7 +173564,7 @@ var ts; ? originalLocation : location; } - configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: ".concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); } updateProjectIfDirty(configuredProject); var projectContainsOriginalInfo = function (project) { @@ -172872,7 +173576,7 @@ var ts; configuredProject = forEachResolvedProjectReferenceProject(configuredProject, fileName, function (child) { updateProjectIfDirty(child); return projectContainsOriginalInfo(child) ? child : undefined; - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + configuredProject.projectName + " to find possible configured project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(configuredProject.projectName, " to find possible configured project for original file: ").concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); if (!configuredProject) return undefined; if (configuredProject === project) @@ -172926,7 +173630,7 @@ var ts; if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { - project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for " + info.fileName + " to open"); + project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for ".concat(info.fileName, " to open")); defaultConfigProjectIsCreated = true; } else { @@ -172956,7 +173660,7 @@ var ts; if (!projectForConfigFileDiag && child.containsScriptInfo(info)) { projectForConfigFileDiag = child; } - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + project.projectName + " to find possible configured project for " + info.fileName + " to open"); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(project.projectName, " to find possible configured project for ").concat(info.fileName, " to open")); } // Send the event only if the project got created as part of this open request and info is part of the project if (projectForConfigFileDiag) { @@ -173018,7 +173722,7 @@ var ts; return; // find or delay load the project var ancestor = this.findConfiguredProjectByProjectName(configFileName) || - this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project " + project.getProjectName() + " of open file " + info.fileName); + this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project ".concat(project.getProjectName(), " of open file ").concat(info.fileName)); if (ancestor.isInitialLoadPending()) { // Set a potential project reference ancestor.setPotentialProjectReference(project.canonicalConfigFilePath); @@ -173061,7 +173765,7 @@ var ts; // Load this project, var configFileName = server.toNormalizedPath(child.sourceFile.fileName); var childProject = project.projectService.findConfiguredProjectByProjectName(configFileName) || - project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : " + project.projectName + " as it references project " + referencedProject.sourceFile.fileName); + project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : ".concat(project.projectName, " as it references project ").concat(referencedProject.sourceFile.fileName)); updateProjectIfDirty(childProject); // Ensure children for this project this.ensureProjectChildren(childProject, forProjects, seenProjects); @@ -173144,7 +173848,7 @@ var ts; var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo); this.filenameToScriptInfo.forEach(function (info) { // If script info is open or orphan, retain it and its dependencies - if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByAutoImportProvider()) { + if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) { // Otherwise if there is any source info that is alive, this alive too if (!info.sourceMapFilePath) return; @@ -173362,7 +174066,7 @@ var ts; for (var _b = 0, normalizedNames_1 = normalizedNames; _b < normalizedNames_1.length; _b++) { var root = normalizedNames_1[_b]; if (rule.match.test(root)) { - this_3.logger.info("Excluding files based on rule " + name + " matching file '" + root + "'"); + this_3.logger.info("Excluding files based on rule ".concat(name, " matching file '").concat(root, "'")); // If the file matches, collect its types packages and exclude rules if (rule.types) { for (var _c = 0, _d = rule.types; _c < _d.length; _c++) { @@ -173387,7 +174091,7 @@ var ts; if (typeof groupNumberOrString === "number") { if (!ts.isString(groups[groupNumberOrString])) { // Specification was wrong - exclude nothing! - _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + _this.logger.info("Incorrect RegExp specification in safelist rule ".concat(name, " - not enough groups")); // * can't appear in a filename; escape it because it's feeding into a RegExp return "\\*"; } @@ -173435,7 +174139,7 @@ var ts; var cleanedTypingName = ts.removeMinAndVersionNumbers(inferredTypingName); var typeName = this_4.legacySafelist.get(cleanedTypingName); if (typeName !== undefined) { - this_4.logger.info("Excluded '" + normalizedNames[i] + "' because it matched " + cleanedTypingName + " from the legacy safelist"); + this_4.logger.info("Excluded '".concat(normalizedNames[i], "' because it matched ").concat(cleanedTypingName, " from the legacy safelist")); excludedFiles.push(normalizedNames[i]); // *exclude* it from the project... exclude = true; @@ -173565,8 +174269,8 @@ var ts; if (!project) { // errors are stored in the project, do not need to update the graph project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? - this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName) : - this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName); + this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)) : + this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)); } if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { // keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project @@ -173586,7 +174290,7 @@ var ts; ProjectService.prototype.hasDeferredExtension = function () { for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { // TODO: GH#18217 var extension = _a[_i]; - if (extension.scriptKind === 7 /* Deferred */) { + if (extension.scriptKind === 7 /* ScriptKind.Deferred */) { return true; } } @@ -173610,11 +174314,11 @@ var ts; var processDirectory = function (directory) { switch (packageJsonCache.directoryHasPackageJson(directory)) { // Sync and check same directory again - case 3 /* Maybe */: + case 3 /* Ternary.Maybe */: packageJsonCache.searchDirectoryAndAncestors(directory); return processDirectory(directory); // Check package.json - case -1 /* True */: + case -1 /* Ternary.True */: var packageJsonFileName = ts.combinePaths(directory, "package.json"); _this.watchPackageJsonFile(packageJsonFileName); var info = packageJsonCache.getInDirectory(directory); @@ -173633,9 +174337,9 @@ var ts; var _this = this; return ts.forEachAncestorDirectory(fileName, function (directory) { switch (_this.packageJsonCache.directoryHasPackageJson(_this.toPath(directory))) { - case -1 /* True */: return directory; - case 0 /* False */: return undefined; - case 3 /* Maybe */: + case -1 /* Ternary.True */: return directory; + case 0 /* Ternary.False */: return undefined; + case 3 /* Ternary.Maybe */: return _this.host.fileExists(ts.combinePaths(directory, "package.json")) ? directory : undefined; @@ -173674,9 +174378,9 @@ var ts; /*@internal*/ ProjectService.prototype.includePackageJsonAutoImports = function () { switch (this.hostConfiguration.preferences.includePackageJsonAutoImports) { - case "on": return 1 /* On */; - case "off": return 0 /* Off */; - default: return 2 /* Auto */; + case "on": return 1 /* PackageJsonAutoImportPreference.On */; + case "off": return 0 /* PackageJsonAutoImportPreference.Off */; + default: return 2 /* PackageJsonAutoImportPreference.Auto */; } }; /*@internal*/ @@ -173742,7 +174446,7 @@ var ts; return cache.get(toFileName); }, set: function (fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) { - ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isAutoImportable*/ true)); + ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false)); // If any module specifiers were generated based off paths in node_modules, // a package.json file in that package was read and is an input to the cached. // Instead of watching each individual package.json file, set up a wildcard @@ -173768,17 +174472,17 @@ var ts; info.modulePaths = modulePaths; } else { - cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isAutoImportable*/ undefined)); + cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined)); } }, - setIsAutoImportable: function (fromFileName, toFileName, preferences, options, isAutoImportable) { + setBlockedByPackageJsonDependencies: function (fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) { var cache = ensureCache(fromFileName, preferences, options); var info = cache.get(toFileName); if (info) { - info.isAutoImportable = isAutoImportable; + info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies; } else { - cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isAutoImportable)); + cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies)); } }, clear: function () { @@ -173804,10 +174508,10 @@ var ts; return cache || (cache = new ts.Map()); } function key(fromFileName, preferences, options) { - return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode; + return "".concat(fromFileName, ",").concat(preferences.importModuleSpecifierEnding, ",").concat(preferences.importModuleSpecifierPreference, ",").concat(options.overrideImportMode); } - function createInfo(modulePaths, moduleSpecifiers, isAutoImportable) { - return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isAutoImportable: isAutoImportable }; + function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) { + return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies }; } } server.createModuleSpecifierCache = createModuleSpecifierCache; @@ -173835,7 +174539,7 @@ var ts; directoryHasPackageJson: directoryHasPackageJson, searchDirectoryAndAncestors: function (directory) { ts.forEachAncestorDirectory(directory, function (ancestor) { - if (directoryHasPackageJson(ancestor) !== 3 /* Maybe */) { + if (directoryHasPackageJson(ancestor) !== 3 /* Ternary.Maybe */) { return true; } var packageJsonFileName = host.toPath(ts.combinePaths(ancestor, "package.json")); @@ -173854,9 +174558,9 @@ var ts; directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); } function directoryHasPackageJson(directory) { - return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : - directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : - 3 /* Maybe */; + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* Ternary.True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* Ternary.False */ : + 3 /* Ternary.Maybe */; } } server.createPackageJsonCache = createPackageJsonCache; @@ -173963,10 +174667,10 @@ var ts; var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); if (verboseLogging) { - logger.info(msg.type + ":" + server.indent(json)); + logger.info("".concat(msg.type, ":").concat(server.indent(json))); } var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + return "Content-Length: ".concat(1 + len, "\r\n\r\n").concat(json).concat(newLine); } server.formatMessage = formatMessage; /** @@ -174013,10 +174717,10 @@ var ts; try { if (this.operationHost.isCancellationRequested()) { stop = true; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId, early: true }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "stepAction", { seq: this.requestId }); action(this); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -174027,11 +174731,11 @@ var ts; stop = true; // ignore cancellation request if (e instanceof ts.OperationCanceledException) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message }); - this.operationHost.logError(e, "delayed processing of request " + this.requestId); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepError", { seq: this.requestId, message: e.message }); + this.operationHost.logError(e, "delayed processing of request ".concat(this.requestId)); } } if (stop || !this.hasPendingWork()) { @@ -174089,7 +174793,8 @@ var ts; var providePrefixAndSuffixTextForRename = _a.providePrefixAndSuffixTextForRename; var outputs = []; var seen = createDocumentSpanSet(); - combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, tryAddToTodo) { + combineProjectOutputWorker(projects, defaultProject, initialLocation, + /*isForRename*/ true, function (project, location, tryAddToTodo) { var projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename); if (projectOutputs) { for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) { @@ -174103,18 +174808,20 @@ var ts; }); return outputs; } - function getDefinitionLocation(defaultProject, initialLocation) { - var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos); + function getDefinitionLocation(defaultProject, initialLocation, isForRename) { + var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, isForRename); var info = infos && ts.firstOrUndefined(infos); return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined; } function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) { - logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName()); + combineProjectOutputWorker(projects, defaultProject, initialLocation, + /*isForRename*/ false, function (project, location, getMappedLocation) { + var _a, _b; + logger.info("Finding references to ".concat(location.fileName, " position ").concat(location.pos, " in project ").concat(project.getProjectName())); var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos); if (projectOutputs) { - var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined; + var clearIsDefinition = ((_b = (_a = projectOutputs[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined; var _loop_9 = function (referencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? @@ -174124,8 +174831,8 @@ var ts; symbolToAddTo = { definition: definition, references: [] }; outputs.push(symbolToAddTo); } - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var ref = _b[_a]; + for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) { + var ref = _d[_c]; // If it's in a mapped file, that is added to the todo list by `getMappedLocation`. if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) { if (clearIsDefinition) { @@ -174157,7 +174864,7 @@ var ts; }); } } - function combineProjectOutputWorker(projects, defaultProject, initialLocation, cb) { + function combineProjectOutputWorker(projects, defaultProject, initialLocation, isForRename, cb) { var projectService = defaultProject.projectService; var toDo; var seenProjects = new ts.Set(); @@ -174168,7 +174875,7 @@ var ts; }); // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. if (initialLocation) { - var defaultDefinition_1 = getDefinitionLocation(defaultProject, initialLocation); + var defaultDefinition_1 = getDefinitionLocation(defaultProject, initialLocation, isForRename); if (defaultDefinition_1) { var getGeneratedDefinition_1 = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition_1.fileName) ? defaultDefinition_1 : @@ -174440,6 +175147,9 @@ var ts; _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) { return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); }, + _a[server.CommandNames.FindSourceDefinition] = function (request) { + return _this.requiredResponse(_this.findSourceDefinition(request.arguments)); + }, _a[server.CommandNames.EmitOutput] = function (request) { return _this.requiredResponse(_this.getEmitOutput(request.arguments)); }, @@ -174790,14 +175500,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidPartialSemanticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.PartialSemantic")); }); }); break; case ts.LanguageServiceMode.Syntactic: invalidSyntacticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.Syntactic")); }); }); break; @@ -174872,7 +175582,7 @@ var ts; }; Session.prototype.projectsUpdatedInBackgroundEvent = function (openFiles) { var _this = this; - this.projectService.logger.info("got projects updated in background, updating diagnostics for " + openFiles); + this.projectService.logger.info("got projects updated in background, updating diagnostics for ".concat(openFiles)); if (openFiles.length) { if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { // For now only queue error checking for open files. We can change this to include non open files as well @@ -174902,17 +175612,17 @@ var ts; var scriptInfo = project.getScriptInfoForNormalizedPath(file); if (scriptInfo) { var text = ts.getSnapshotText(scriptInfo.getSnapshot()); - msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; + msg += "\n\nFile text of ".concat(fileRequest.file, ":").concat(server.indent(text), "\n"); } } catch (_b) { } // eslint-disable-line no-empty } if (err.ProgramFiles) { - msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; + msg += "\n\nProgram files: ".concat(JSON.stringify(err.ProgramFiles), "\n"); msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { - msg += "\nProject '" + project.projectName + "' (" + server.ProjectKind[project.projectKind] + ") " + counter_1 + "\n"; + msg += "\nProject '".concat(project.projectName, "' (").concat(server.ProjectKind[project.projectKind], ") ").concat(counter_1, "\n"); msg += project.filesToString(/*writeProjectFileNames*/ true); msg += "\n-----------------------------------------------\n"; counter_1++; @@ -174927,7 +175637,7 @@ var ts; Session.prototype.send = function (msg) { if (msg.type === "event" && !this.canUseEvents) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + this.logger.info("Session does not support events: ignored event: ".concat(JSON.stringify(msg))); } return; } @@ -174935,7 +175645,7 @@ var ts; }; Session.prototype.writeMessage = function (msg) { var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); - ts.perfLogger.logEvent("Response message size: " + msgText.length); + ts.perfLogger.logEvent("Response message size: ".concat(msgText.length)); this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { @@ -174987,7 +175697,7 @@ var ts; this.send(res); }; Session.prototype.semanticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file) ? server.emptyArray : project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; }); @@ -174995,12 +175705,12 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.syntacticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.suggestionCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; @@ -175078,7 +175788,7 @@ var ts; if (!projects) { return; } - this.logger.info("cleaning " + caption); + this.logger.info("cleaning ".concat(caption)); for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { var p = projects_4[_i]; p.getLanguageService(/*ensureSynchronized*/ false).cleanupSemanticCache(); @@ -175099,7 +175809,7 @@ var ts; }; Session.prototype.getEncodedSemanticClassifications = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var format = args.format === "2020" ? "2020" /* TwentyTwenty */ : "original" /* Original */; + var format = args.format === "2020" ? "2020" /* SemanticClassificationFormat.TwentyTwenty */ : "original" /* SemanticClassificationFormat.Original */; return project.getLanguageService().getEncodedSemanticClassifications(file, args, format); }; Session.prototype.getProject = function (projectFileName) { @@ -175181,7 +175891,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified }); + return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -175208,6 +175918,152 @@ var ts; textSpan: textSpan, }; }; + Session.prototype.findSourceDefinition = function (args) { + var _a; + var _b = this.getFileAndProject(args), file = _b.file, project = _b.project; + var position = this.getPositionInFile(args, file); + var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position); + var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice(); + var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) || + ts.some(definitions, function (d) { return !!d.failedAliasResolution; })); + if (needsJsResolution) { + var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual); + definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); }); + var noDtsProject = project.getNoDtsResolutionProject([file]); + var ls = noDtsProject.getLanguageService(); + var jsDefinitions = (_a = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file; }); + if (ts.some(jsDefinitions)) { + for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) { + var jsDefinition = jsDefinitions_1[_i]; + if (jsDefinition.unverified) { + var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram()); + if (ts.some(refined)) { + for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) { + var def = refined_1[_c]; + definitionSet_1.add(def); + } + continue; + } + } + definitionSet_1.add(jsDefinition); + } + } + else { + var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }); + for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) { + var candidate = _e[_d]; + var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject); + if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) { + continue; + } + var noDtsProgram = ls.getProgram(); + var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch)); + for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) { + var match = _g[_f]; + definitionSet_1.add(match); + } + } + } + definitions = ts.arrayFrom(definitionSet_1.values()); + } + definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; }); + return this.mapDefinitionInfo(definitions, project); + function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) { + var _a; + var nodeModulesPathParts = ts.getNodeModulePathParts(fileName); + if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) { + // Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up. + var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex); + var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); + var compilerOptions = project.getCompilationSettings(); + var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions); + if (!packageJson) + return undefined; + // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext - + // Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be + // resolved from the package root under --moduleResolution node + var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache()); + // This substring is correct only because we checked for a single `/node_modules/` at the top. + var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex); + var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart)); + var path_1 = project.toPath(fileName); + if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) { + // This file was the main entrypoint of a package. Try to resolve that same package name with + // the auxiliary project that only resolves to implementation files. + var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0]; + return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName; + } + else { + // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package. + var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1); + var specifier = "".concat(packageName, "/").concat(ts.removeFileExtension(pathToFileInPackage)); + var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0]; + return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName; + } + } + // We're not in node_modules, and we only get to this function if non-dts module resolution failed. + // I'm not sure what else I can do here that isn't already covered by that module resolution. + return undefined; + } + // In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition + // for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later. + function getAmbientCandidatesByClimbingAccessChain() { + var ls = project.getLanguageService(); + var program = ls.getProgram(); + var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position); + if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) { + return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) { + var _a; + if (nameInChain === initialNode) + return undefined; + var candidates = (_a = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }).map(function (d) { return ({ + fileName: d.fileName, + name: ts.getTextOfIdentifierOrLiteral(initialNode) + }); }); + if (ts.some(candidates)) { + return candidates; + } + }) || server.emptyArray; + } + return server.emptyArray; + } + function tryRefineDefinition(definition, program, noDtsProgram) { + var _a; + var fileToSearch = noDtsProgram.getSourceFile(definition.fileName); + if (!fileToSearch) { + return undefined; + } + var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position); + var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode); + var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* SyntaxKind.ImportSpecifier */); + if (!importSpecifier) + return undefined; + var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text; + return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram); + } + function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) { + var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch); + return ts.mapDefined(matches, function (match) { + var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match); + var decl = ts.getDeclarationFromName(match); + if (symbol && decl) { + // I think the last argument to this is supposed to be the start node, but it doesn't seem important. + // Callers internal to GoToDefinition already get confused about this. + return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true); + } + }); + } + function ensureRoot(project, fileName) { + var info = project.getScriptInfo(fileName); + if (!info) + return false; + if (!project.containsScriptInfo(info)) { + project.addRoot(info); + project.updateGraph(); + } + return true; + } + }; Session.prototype.getEmitOutput = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; if (!project.shouldEmitFile(project.getScriptInfo(file))) { @@ -175508,7 +176364,7 @@ var ts; var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); }); return { refs: refs, - symbolName: "\"" + args.file + "\"" + symbolName: "\"".concat(args.file, "\"") }; }; /** @@ -175709,7 +176565,7 @@ var ts; var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }), project.projectService.getFormatCodeOptions(file)); if (completions === undefined) return undefined; - if (kind === "completions-full" /* CompletionsFull */) + if (kind === "completions-full" /* protocol.CommandTypes.CompletionsFull */) return completions; var prefix = args.prefix || ""; var entries = ts.mapDefined(completions.entries, function (entry) { @@ -175736,7 +176592,7 @@ var ts; }; } }); - if (kind === "completions" /* Completions */) { + if (kind === "completions" /* protocol.CommandTypes.Completions */) { if (completions.metadata) entries.metadata = completions.metadata; return entries; @@ -175771,7 +176627,7 @@ var ts; return undefined; } var compilationSettings = project.getCompilationSettings(); - if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) { + if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) { // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled return undefined; } @@ -176135,7 +176991,7 @@ var ts; }); var badCode = args.errorCodes.find(function (c) { return !existingDiagCodes_1.includes(c); }); if (badCode !== undefined) { - e.message = "BADCLIENT: Bad error code, " + badCode + " not found in range " + startPosition + ".." + endPosition + " (found: " + existingDiagCodes_1.join(", ") + "); could have caused this error:\n" + e.message; + e.message = "BADCLIENT: Bad error code, ".concat(badCode, " not found in range ").concat(startPosition, "..").concat(endPosition, " (found: ").concat(existingDiagCodes_1.join(", "), "); could have caused this error:\n").concat(e.message); } throw e; } @@ -176251,7 +177107,7 @@ var ts; else { var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217 if (!info.isScriptOpen()) { - if (ts.fileExtensionIs(fileNameInProject, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileNameInProject)) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -176412,7 +177268,7 @@ var ts; }; Session.prototype.addProtocolHandler = function (command, handler) { if (this.handlers.has(command)) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); + throw new Error("Protocol handler already exists for command \"".concat(command, "\"")); } this.handlers.set(command, handler); }; @@ -176441,8 +177297,8 @@ var ts; return this.executeWithRequestId(request.seq, function () { return handler(request); }); } else { - this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err); - this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: " + request.command); + this.logger.msg("Unrecognized JSON command:".concat(server.stringifyIndented(request)), server.Msg.Err); + this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: ".concat(request.command)); return { responseRequired: false }; } }; @@ -176453,7 +177309,7 @@ var ts; if (this.logger.hasLevel(server.LogLevel.requestTime)) { start = this.hrtime(); if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request:" + server.indent(this.toStringMessage(message))); + this.logger.info("request:".concat(server.indent(this.toStringMessage(message)))); } } var request; @@ -176461,23 +177317,23 @@ var ts; try { request = this.parseMessage(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "request", { seq: request.seq, command: request.command }); ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": elapsed time (in milliseconds) ").concat(elapsedTime)); } else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": async elapsed time (in milliseconds) ").concat(elapsedTime)); } } // Note: Log before writing the response, else the editor can complete its activity before the server does ts.perfLogger.logStopCommand("" + request.command, "Success"); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "response", { seq: request.seq, command: request.command, success: !!response }); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -176491,13 +177347,13 @@ var ts; if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, this.toStringMessage(message), relevantFile); ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -176608,7 +177464,7 @@ var ts; this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = 2 /* Entire */; + this.state = 2 /* CharRangeSection.Entire */; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -176699,7 +177555,7 @@ var ts; // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { - this.state = 4 /* End */; + this.state = 4 /* CharRangeSection.End */; } // always pop stack because post only called when child has been visited this.stack.pop(); @@ -176707,9 +177563,9 @@ var ts; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { // currentNode corresponds to parent, but in the new tree var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === 2 /* Entire */) && (nodeType === 1 /* Start */)) { + if ((this.state === 2 /* CharRangeSection.Entire */) && (nodeType === 1 /* CharRangeSection.Start */)) { // if range is on single line, we will never make this state transition - this.state = 1 /* Start */; + this.state = 1 /* CharRangeSection.Start */; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -176722,14 +177578,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case 0 /* PreStart */: + case 0 /* CharRangeSection.PreStart */: this.goSubtree = false; - if (this.state !== 4 /* End */) { + if (this.state !== 4 /* CharRangeSection.End */) { currentNode.add(lineCollection); } break; - case 1 /* Start */: - if (this.state === 4 /* End */) { + case 1 /* CharRangeSection.Start */: + if (this.state === 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -176738,8 +177594,8 @@ var ts; this.startPath.push(child); } break; - case 2 /* Entire */: - if (this.state !== 4 /* End */) { + case 2 /* CharRangeSection.Entire */: + if (this.state !== 4 /* CharRangeSection.End */) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -176752,11 +177608,11 @@ var ts; } } break; - case 3 /* Mid */: + case 3 /* CharRangeSection.Mid */: this.goSubtree = false; break; - case 4 /* End */: - if (this.state !== 4 /* End */) { + case 4 /* CharRangeSection.End */: + if (this.state !== 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -176767,9 +177623,9 @@ var ts; } } break; - case 5 /* PostEnd */: + case 5 /* CharRangeSection.PostEnd */: this.goSubtree = false; - if (this.state !== 1 /* Start */) { + if (this.state !== 1 /* CharRangeSection.Start */) { currentNode.add(lineCollection); } break; @@ -176780,10 +177636,10 @@ var ts; }; // just gather text from the leaves EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === 1 /* Start */) { + if (this.state === 1 /* CharRangeSection.Start */) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === 2 /* Entire */) { + else if (this.state === 2 /* CharRangeSection.Entire */) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -177141,20 +177997,20 @@ var ts; // find sub-tree containing start var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* PreStart */); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* CharRangeSection.PreStart */); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } // Case I: both start and end of range in same subtree if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* Entire */)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* CharRangeSection.Entire */)) { return; } } else { // Case II: start and end of range in different subtrees (possibly with subtrees in the middle) - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* Start */)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* CharRangeSection.Start */)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -177162,7 +178018,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* Mid */)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* CharRangeSection.Mid */)) { return; } adjustedLength -= childCharCount; @@ -177170,7 +178026,7 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* End */)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* CharRangeSection.End */)) { return; } } @@ -177180,7 +178036,7 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, 5 /* PostEnd */); + this.skipChild(0, 0, ej, walkFns, 5 /* CharRangeSection.PostEnd */); } } } @@ -177988,11 +178844,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -178039,7 +178895,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -178076,7 +178932,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -178217,9 +179073,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -178246,7 +179102,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 45eed1b64845b..fb0a5a0c1e756 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2172,7 +2172,9 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export interface WriteFileCallbackData { + } + export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -2394,7 +2396,6 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, - NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2892,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2901,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3073,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4817,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6434,7 +6435,18 @@ declare namespace ts { argumentIndex: number; argumentCount: number; } + enum CompletionInfoFlags { + None = 0, + MayIncludeAutoImports = 1, + IsImportStatementCompletion = 2, + IsContinuation = 4, + ResolvedModuleSpecifiers = 8, + ResolvedModuleSpecifiersBeyondLimit = 16, + MayIncludeMethodSnippets = 32 + } interface CompletionInfo { + /** For performance telemetry. */ + flags?: CompletionInfoFlags; /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; @@ -6810,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6829,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. diff --git a/lib/typescript.js b/lib/typescript.js index d2bf2eb475ba2..946220e91b742 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -21,7 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -294,7 +294,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "".concat(ts.versionMajorMinor, ".1-rc"); /* @internal */ var Comparison; (function (Comparison) { @@ -341,7 +341,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -1033,9 +1033,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -1071,7 +1071,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -1125,27 +1125,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1385,12 +1385,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1844,7 +1844,7 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ @@ -1935,7 +1935,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -2007,11 +2007,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -2029,7 +2029,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -2046,14 +2046,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -2084,13 +2084,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -2120,7 +2120,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2181,9 +2181,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2302,24 +2302,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2329,7 +2329,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2385,7 +2385,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2485,12 +2485,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2621,7 +2621,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2700,7 +2700,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2708,12 +2708,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2723,26 +2723,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2773,42 +2773,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2829,7 +2829,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2850,7 +2850,7 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "" + result + (result ? "|" : "") + enumName; + result = "".concat(result).concat(result ? "|" : "").concat(enumName); remainingFlags &= ~enumValue; } } @@ -2947,20 +2947,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2999,7 +2999,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -3051,10 +3051,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -3063,35 +3063,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -3123,11 +3123,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -3159,7 +3159,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3206,10 +3206,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3323,9 +3323,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3340,11 +3340,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3373,11 +3373,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3394,7 +3394,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3611,7 +3611,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3909,7 +3909,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3921,11 +3921,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -4015,20 +4015,20 @@ var ts; } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -4064,7 +4064,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -4073,7 +4073,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -4081,7 +4081,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -4090,7 +4090,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -4100,7 +4100,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -4108,7 +4108,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -4117,7 +4117,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -4135,7 +4135,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4854,7 +4854,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; - NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -5471,10 +5470,11 @@ var ts; ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16"; ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var ModuleDetectionKind; @@ -5484,7 +5484,7 @@ var ts; */ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy"; /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto"; /** @@ -5529,8 +5529,8 @@ var ts; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + ModuleKind[ModuleKind["Node16"] = 100] = "Node16"; ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); var JsxEmit; @@ -6066,37 +6066,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6168,7 +6168,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6385,7 +6385,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6637,7 +6637,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6650,7 +6650,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6666,7 +6666,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6689,7 +6689,7 @@ var ts; var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6784,7 +6784,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6839,7 +6839,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6871,7 +6871,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -7126,7 +7126,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7135,7 +7135,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7151,7 +7151,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7253,7 +7253,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -7278,7 +7278,7 @@ var ts; } } if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -7294,7 +7294,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7445,8 +7445,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7458,10 +7458,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7525,8 +7525,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7549,7 +7549,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7636,16 +7636,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7659,18 +7659,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7690,7 +7690,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7767,7 +7767,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -8051,17 +8051,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -8078,7 +8078,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8452,6 +8452,7 @@ var ts; _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), @@ -8463,10 +8464,10 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), - Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -8481,7 +8482,7 @@ var ts; 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_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_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -8512,7 +8513,7 @@ var ts; await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -8564,7 +8565,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), - Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), @@ -8582,7 +8583,7 @@ var ts; Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), - Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."), + Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."), resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), @@ -8593,7 +8594,7 @@ var ts; An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), - auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8602,7 +8603,8 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), - This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -8853,7 +8855,6 @@ var ts; A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), - 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."), Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), 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."), @@ -8911,6 +8912,7 @@ var ts; _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -9066,6 +9068,7 @@ var ts; This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), @@ -9079,8 +9082,8 @@ var ts; Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), @@ -9191,6 +9194,7 @@ var ts; This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -9746,7 +9750,6 @@ var ts; This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), - JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -10056,100 +10059,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10238,16 +10241,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10276,17 +10279,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10311,7 +10314,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10389,18 +10392,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10414,50 +10417,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10471,29 +10474,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10504,10 +10507,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10517,24 +10520,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10542,7 +10545,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10566,8 +10569,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10578,18 +10581,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10650,12 +10653,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10665,20 +10668,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10689,7 +10692,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10714,7 +10717,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10769,17 +10772,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10798,7 +10801,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10821,15 +10824,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10884,8 +10887,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10909,7 +10912,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10919,15 +10922,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10940,7 +10943,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10952,10 +10955,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -11013,8 +11016,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11029,11 +11032,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -11043,7 +11046,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -11057,7 +11060,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11067,7 +11070,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -11075,7 +11078,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11088,7 +11091,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -11096,28 +11099,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11125,10 +11128,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11151,47 +11154,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11199,29 +11202,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11229,14 +11232,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11269,7 +11272,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11285,7 +11288,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11295,7 +11298,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11313,11 +11316,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11326,7 +11329,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11345,14 +11348,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11363,8 +11366,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11379,101 +11382,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11482,98 +11485,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11586,20 +11589,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11607,7 +11610,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11619,18 +11622,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11638,10 +11641,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11649,10 +11652,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11660,175 +11663,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11838,7 +11841,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11849,23 +11852,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11879,41 +11882,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11921,13 +11924,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11936,19 +11939,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11958,7 +11961,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11979,9 +11982,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11989,7 +11992,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -12003,42 +12006,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -12046,20 +12049,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -12082,7 +12085,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -12095,16 +12098,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12125,10 +12128,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12140,86 +12143,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12294,9 +12297,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12362,23 +12365,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12586,9 +12589,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12596,7 +12599,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12626,14 +12629,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12747,7 +12750,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12765,7 +12768,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12776,7 +12779,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12806,30 +12809,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12864,42 +12867,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -13192,16 +13195,16 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a @@ -13212,7 +13215,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13239,33 +13242,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13300,7 +13303,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13309,25 +13312,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13336,12 +13339,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13357,7 +13360,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13366,7 +13369,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13387,7 +13390,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13397,7 +13400,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13406,8 +13409,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13416,13 +13419,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13434,13 +13437,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13458,20 +13461,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13479,12 +13482,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13493,24 +13496,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13530,18 +13533,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13550,14 +13553,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13572,30 +13575,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13605,13 +13608,13 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13620,12 +13623,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13640,8 +13643,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13652,8 +13655,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13661,15 +13664,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13678,9 +13681,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13701,8 +13704,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13711,10 +13714,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13726,8 +13729,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13736,26 +13739,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13763,13 +13766,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13779,36 +13782,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13821,13 +13824,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13836,11 +13839,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13857,15 +13860,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13873,8 +13876,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13885,13 +13888,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13909,18 +13912,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13944,115 +13947,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14079,10 +14082,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14096,76 +14099,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14175,15 +14178,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14209,13 +14212,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14223,12 +14226,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14257,11 +14260,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion @@ -14302,7 +14305,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14463,11 +14466,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14498,28 +14501,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14530,16 +14533,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14554,7 +14557,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14607,7 +14610,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14641,7 +14644,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14673,9 +14676,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14687,13 +14690,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14702,7 +14705,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14710,10 +14713,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14724,7 +14727,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14735,7 +14738,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14896,62 +14899,62 @@ var ts; var _a; // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14966,21 +14969,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -15004,16 +15007,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -15025,9 +15028,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -15039,7 +15042,7 @@ var ts; } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isCommonJSContainingModuleKind(kind) { - return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext; } function isEffectiveExternalModule(node, compilerOptions) { return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); @@ -15051,10 +15054,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15084,24 +15087,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15111,9 +15114,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15123,25 +15126,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15151,25 +15154,29 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; } } ts.isAnyImportSyntax = isAnyImportSyntax; + function isAnyImportOrBareOrAccessedRequire(node) { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15210,19 +15217,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15237,21 +15244,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15341,7 +15348,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15355,7 +15362,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15364,29 +15371,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15418,36 +15425,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15456,12 +15463,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15480,24 +15487,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15506,48 +15513,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15556,40 +15563,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15614,23 +15621,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15640,23 +15647,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15679,10 +15686,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15692,12 +15699,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15705,14 +15712,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15724,21 +15731,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15749,13 +15756,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15766,7 +15773,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15774,30 +15781,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15859,14 +15866,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15881,9 +15888,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15894,27 +15901,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15927,17 +15934,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15961,9 +15968,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15985,28 +15992,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16022,21 +16029,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -16045,8 +16052,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -16054,34 +16061,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16089,10 +16096,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16105,25 +16112,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16139,11 +16146,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16159,9 +16166,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16169,64 +16176,64 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16236,49 +16243,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16286,10 +16293,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16297,7 +16304,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16310,7 +16317,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16322,11 +16329,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16334,7 +16341,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16342,15 +16349,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16376,7 +16383,7 @@ var ts; } ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { - if (node.kind === 203 /* BindingElement */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && @@ -16390,11 +16397,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16405,7 +16412,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16432,7 +16439,7 @@ var ts; * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16458,11 +16465,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16480,7 +16487,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16488,7 +16495,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16496,8 +16503,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16519,17 +16526,13 @@ var ts; if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - var nameOrArgument = getNameOrArgument(initializer); - if (ts.isPrivateIdentifier(nameOrArgument)) { - ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -16563,7 +16566,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16588,14 +16591,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16614,23 +16617,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16667,17 +16670,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16689,14 +16692,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16707,12 +16710,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16720,7 +16723,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16733,18 +16736,18 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { - var _a, _b, _c; + var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: - return node.initializer.arguments[0].text; - case 266 /* ImportDeclaration */: - return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: - return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + case 254 /* SyntaxKind.VariableDeclaration */: + return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; + case 266 /* SyntaxKind.ImportDeclaration */: + return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); } @@ -16756,14 +16759,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16773,17 +16776,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16791,11 +16794,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16803,7 +16806,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16824,13 +16827,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16844,7 +16847,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16854,27 +16857,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16886,7 +16889,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16901,11 +16904,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16934,13 +16937,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16951,7 +16954,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16975,7 +16978,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -17041,7 +17044,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -17058,41 +17061,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17103,7 +17106,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17112,22 +17115,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17144,11 +17147,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17158,7 +17161,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17167,18 +17170,18 @@ var ts; ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17199,13 +17202,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17216,13 +17219,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17231,7 +17234,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17239,27 +17242,30 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - // Any name in an export specifier or JSX Attribute + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + // Any name in an export specifier or JSX Attribute or Jsx Element return true; } return false; @@ -17275,36 +17281,44 @@ var ts; // export = // export default // module.exports = - // {} - // {name: } + // module.exports.x = + // const x = require("...") + // const { x } = require("...") + // const x = require("...").y + // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 297 /* ShorthandPropertyAssignment */ || - node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { + return true; + } + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) + && ts.isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17323,7 +17337,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17340,7 +17354,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17349,7 +17363,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17362,7 +17376,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17389,11 +17403,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17401,7 +17415,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17420,7 +17434,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17433,38 +17447,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17474,7 +17488,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17491,7 +17505,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17501,19 +17515,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17526,10 +17540,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17545,11 +17559,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17564,7 +17578,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17573,11 +17587,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17585,15 +17599,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17612,58 +17626,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17842,129 +17856,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17974,9 +17988,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18091,9 +18105,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18108,8 +18122,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18139,13 +18153,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18164,13 +18178,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18187,6 +18201,10 @@ var ts; return indentStrings[1].length; } ts.getIndentSize = getIndentSize; + function isNightly() { + return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders"); + } + ts.isNightly = isNightly; function createTextWriter(newLine) { var output; var indent; @@ -18411,12 +18429,22 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; + /** + * This function is an inverse of `getDeclarationEmitExtensionForPath`. + */ + function getPossibleOriginalInputExtensionForExtension(path) { + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; + } + ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { return options.outFile || options.out; } @@ -18476,10 +18504,10 @@ var ts; return ts.combinePaths(newDirPath, sourceFilePath); } ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) { diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } ts.writeFile = writeFile; function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) { @@ -18542,7 +18570,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18552,11 +18580,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18567,10 +18595,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18590,10 +18618,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18642,7 +18670,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18759,7 +18787,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18834,7 +18862,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18846,11 +18874,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18867,23 +18895,23 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18895,16 +18923,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18929,22 +18957,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18964,14 +18992,14 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18983,22 +19011,22 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -19006,15 +19034,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -19022,7 +19050,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19035,14 +19063,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19054,8 +19082,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19065,33 +19093,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19122,10 +19150,15 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfAccessExpression(node) { + return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { return ts.isQualifiedName(node.parent) && node.parent.right === node || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -19133,12 +19166,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19154,7 +19187,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19325,9 +19358,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19470,8 +19503,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19495,32 +19528,32 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SyntaxKind.SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19529,11 +19562,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19548,47 +19581,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19658,9 +19691,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19671,11 +19704,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19722,44 +19755,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19767,7 +19800,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19777,31 +19810,66 @@ var ts; return expr; } ts.getLeftmostAccessExpression = getLeftmostAccessExpression; + function forEachNameInAccessChainWalkingLeft(name, action) { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + function walkAccessExpression(access) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { + if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { + var res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + // Chain interrupted by non-static-name access 'x[expr()].y.z' + return undefined; + } + } + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (ts.isIdentifier(access.expression)) { + // End of chain at Identifier 'x.y.z' + return action(access.expression); + } + // End of chain at non-Identifier 'x().y.z' + return undefined; + } + } + ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19835,9 +19903,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19846,8 +19914,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19855,8 +19923,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20051,7 +20119,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20060,43 +20128,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20106,16 +20174,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20124,7 +20192,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20156,15 +20224,15 @@ var ts; file.externalModuleIndicator = ts.isFileProbablyExternalModule(file); }; case ts.ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } var combined_1 = ts.or.apply(void 0, checks); @@ -20175,15 +20243,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20193,8 +20261,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -20219,7 +20287,7 @@ var ts; case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; default: @@ -20244,7 +20312,7 @@ var ts; return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; } @@ -20280,7 +20348,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20297,14 +20365,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20312,13 +20380,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20417,9 +20485,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20432,7 +20500,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20441,7 +20509,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20459,10 +20527,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20484,7 +20552,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20521,11 +20589,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20562,7 +20630,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20687,43 +20755,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20731,7 +20800,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20742,11 +20811,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20777,7 +20846,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20830,11 +20899,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20843,7 +20912,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20952,23 +21021,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20984,10 +21053,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21022,7 +21091,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21033,34 +21102,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21201,7 +21270,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21221,18 +21290,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return node.parent.decorators; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21240,45 +21309,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21290,7 +21359,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21308,7 +21377,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21317,7 +21386,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21356,7 +21425,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21376,42 +21445,47 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; + function getParameterTypeNode(parameter) { + var _a; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + } + ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); /* @internal */ var ts; @@ -21534,28 +21608,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21566,7 +21640,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21586,8 +21660,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21603,7 +21677,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21621,10 +21695,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21637,7 +21711,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21645,11 +21719,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21663,7 +21737,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21680,10 +21754,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21713,8 +21787,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21727,9 +21801,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21749,7 +21823,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21771,7 +21845,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21780,21 +21854,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21812,16 +21886,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21833,8 +21907,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21849,8 +21923,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21867,14 +21941,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21894,9 +21968,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22090,11 +22164,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22152,10 +22226,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22286,12 +22360,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22447,18 +22521,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22494,30 +22568,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22585,38 +22659,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22720,11 +22794,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22742,7 +22816,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) { @@ -22753,7 +22827,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseSignatureDeclaration(updated, original) { @@ -22765,9 +22839,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseFunctionLikeDeclaration(updated, original) { @@ -22801,7 +22875,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22814,21 +22888,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22837,7 +22911,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22848,19 +22922,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22870,10 +22944,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22892,8 +22966,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22905,9 +22979,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22917,25 +22991,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22943,9 +23017,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 8388608 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22955,51 +23029,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 33554432 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 8192 /* ContainsLexicalThis */; + transformFlags = 8192 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23012,23 +23086,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23040,34 +23114,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23075,7 +23149,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23092,12 +23166,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 65536 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23120,11 +23194,11 @@ var ts; name = modifiersOrName; constraint = nameOrConstraint; } - var node = createBaseNamedDeclaration(163 /* TypeParameter */, + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, /*decorators*/ undefined, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateTypeParameterDeclaration(node, modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { @@ -23150,22 +23224,22 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23183,12 +23257,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + 1 /* TransformFlags.ContainsTypeScript */ | + 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; return node; } // @api @@ -23202,11 +23276,11 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23220,18 +23294,18 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + 8388608 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23249,10 +23323,10 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23268,26 +23342,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -23307,11 +23381,11 @@ var ts; } // @api function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, decorators, modifiers, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @api @@ -23324,11 +23398,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23342,7 +23416,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(172 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -23358,7 +23432,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(173 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -23374,11 +23448,11 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23391,11 +23465,11 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23408,10 +23482,10 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23425,10 +23499,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23447,11 +23521,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23464,10 +23538,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23479,11 +23553,11 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23505,10 +23579,10 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23539,10 +23613,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23554,9 +23628,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23567,9 +23641,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23580,9 +23654,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23593,12 +23667,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23612,9 +23686,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23625,9 +23699,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23639,7 +23713,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23649,7 +23723,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23657,7 +23731,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23665,12 +23739,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23684,9 +23758,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23697,10 +23771,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23711,22 +23785,22 @@ var ts; : node; } function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertion; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; @@ -23741,9 +23815,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23754,18 +23828,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23776,10 +23850,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23791,14 +23865,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23814,9 +23888,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23830,16 +23904,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23851,12 +23925,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23867,21 +23941,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 16384 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23903,7 +23977,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23922,7 +23996,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23936,7 +24010,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -23948,8 +24022,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23965,13 +24039,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -23981,7 +24055,7 @@ var ts; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -23992,7 +24066,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -24002,8 +24076,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24019,8 +24093,8 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); @@ -24028,12 +24102,12 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24044,7 +24118,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24053,13 +24127,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 4194304 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24076,8 +24150,8 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); @@ -24087,18 +24161,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24108,7 +24182,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24116,9 +24190,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24132,7 +24206,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -24140,12 +24214,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24159,13 +24233,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24177,7 +24251,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24190,23 +24264,23 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24224,15 +24298,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24249,7 +24323,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24262,7 +24336,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24275,7 +24349,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24288,13 +24362,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24305,17 +24379,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24327,7 +24401,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24336,7 +24410,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24348,7 +24422,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24358,46 +24432,46 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) - return 32768 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return 32768 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24405,7 +24479,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24417,11 +24491,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24443,13 +24517,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24460,8 +24534,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24487,41 +24561,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 524288 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24533,12 +24607,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24549,8 +24623,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24566,17 +24640,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24588,13 +24662,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24606,11 +24680,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24624,33 +24698,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24668,13 +24742,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24686,8 +24760,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24695,7 +24769,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24709,12 +24783,12 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24727,11 +24801,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24744,7 +24818,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24764,7 +24838,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24781,7 +24855,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24798,7 +24872,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24821,7 +24895,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24841,7 +24915,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24851,9 +24925,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24867,11 +24941,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24882,11 +24956,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24897,13 +24971,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24914,7 +24988,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24931,7 +25005,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24948,7 +25022,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24965,7 +25039,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24978,7 +25052,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -24998,17 +25072,17 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25023,17 +25097,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25045,25 +25119,25 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } return node; @@ -25083,14 +25157,14 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25108,9 +25182,9 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25126,9 +25200,9 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25143,12 +25217,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -25162,21 +25236,21 @@ var ts; } // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */, decorators, modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */, decorators, modifiers); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -25190,7 +25264,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25203,7 +25277,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25216,10 +25290,10 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25230,13 +25304,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -25251,14 +25325,14 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25273,7 +25347,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25281,9 +25355,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25296,10 +25370,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25311,10 +25385,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25326,7 +25400,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25340,10 +25414,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25354,12 +25428,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25370,10 +25444,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25384,14 +25458,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25404,13 +25478,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25423,7 +25497,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -25431,7 +25505,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25447,10 +25521,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25461,14 +25535,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25481,7 +25555,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */, + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -25491,10 +25565,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25549,7 +25623,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -25566,7 +25640,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25580,7 +25654,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25592,7 +25666,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25621,7 +25695,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25638,7 +25712,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25656,7 +25730,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25677,7 +25751,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25698,7 +25772,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25716,7 +25790,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25731,13 +25805,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25751,7 +25825,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25763,7 +25837,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25780,7 +25854,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25793,7 +25867,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25806,7 +25880,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25878,7 +25952,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -25890,7 +25964,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -25902,7 +25976,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -25919,7 +25993,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -25927,7 +26001,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25940,7 +26014,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25948,9 +26022,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25964,7 +26038,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25972,9 +26046,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25988,11 +26062,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26003,7 +26077,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26011,7 +26085,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26024,10 +26098,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26039,25 +26113,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26069,11 +26143,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26084,11 +26158,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26099,13 +26173,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26119,7 +26193,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26136,7 +26210,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26149,16 +26223,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26173,7 +26247,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26186,7 +26260,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26201,7 +26275,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -26231,13 +26305,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -26263,12 +26337,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26282,13 +26356,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26303,7 +26377,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26320,7 +26394,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26359,7 +26433,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26374,7 +26448,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26392,28 +26466,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26424,7 +26498,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26432,7 +26506,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26447,7 +26521,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26461,12 +26535,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26489,7 +26563,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26506,7 +26580,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26517,14 +26591,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26546,12 +26620,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26665,11 +26739,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26695,7 +26769,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26716,20 +26790,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26737,7 +26811,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26746,11 +26820,11 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); } @@ -26817,9 +26891,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26838,7 +26912,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26851,7 +26925,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26864,7 +26938,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -26889,9 +26963,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -26908,7 +26982,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -26966,7 +27040,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27155,52 +27229,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27209,14 +27283,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27225,22 +27299,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 33562624 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27252,78 +27326,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 589443072 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 557748224 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 591310848 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537165824 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 536940544 /* ClassExcludes */; - case 171 /* Constructor */: - return 591306752 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 570433536 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 574529536 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 536973312 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536903680 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536887296 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return 536887296 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return 589443072 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return 536870912 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return 557748224 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return 591310848 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return 537165824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return 536940544 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return 591306752 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return 570433536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return 574529536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return 536973312 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return 536903680 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return 536887296 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return 536870912 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return 536870912 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return 536870912 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27333,7 +27407,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27396,50 +27470,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27467,22 +27541,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27510,7 +27584,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27579,7 +27653,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27621,7 +27695,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27630,7 +27704,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27662,7 +27736,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -27898,7 +27972,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -27921,8 +27995,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -27963,7 +28037,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -27998,7 +28072,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28014,7 +28088,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28068,13 +28142,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28087,7 +28161,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28177,13 +28251,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28590,7 +28664,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28599,741 +28673,741 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29341,176 +29415,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29530,7 +29604,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29709,14 +29783,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29755,7 +29829,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29780,14 +29854,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29795,7 +29869,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29824,8 +29898,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29841,26 +29915,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29868,7 +29942,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -29930,7 +30004,7 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -29975,10 +30049,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30097,7 +30171,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30109,11 +30183,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30145,12 +30219,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30168,7 +30242,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30183,7 +30257,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30198,7 +30272,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30213,21 +30287,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30248,29 +30322,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30281,68 +30355,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30350,21 +30424,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30497,7 +30571,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30578,7 +30652,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30598,9 +30672,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30612,14 +30686,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 93 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30631,7 +30705,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30647,20 +30721,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30668,9 +30742,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -30678,7 +30752,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30686,51 +30760,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.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 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30742,345 +30816,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.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 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31089,64 +31163,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31195,7 +31269,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31220,13 +31294,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31274,7 +31348,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31302,8 +31376,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31325,7 +31399,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31423,7 +31497,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31442,25 +31516,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31468,28 +31542,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31507,7 +31581,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31516,10 +31590,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31556,15 +31630,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31596,13 +31670,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31635,7 +31709,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31663,12 +31737,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31686,7 +31760,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31706,8 +31780,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31748,7 +31822,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -31775,16 +31849,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -31825,52 +31899,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -31971,15 +32045,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -31991,7 +32065,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -31999,31 +32073,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32061,7 +32135,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32076,17 +32150,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32096,7 +32170,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32121,24 +32195,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32149,7 +32223,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32216,24 +32290,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32250,7 +32324,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32262,11 +32336,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32290,23 +32364,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32319,23 +32393,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32348,12 +32422,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32381,23 +32455,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32405,9 +32479,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32418,18 +32492,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32438,50 +32512,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32493,42 +32567,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32537,7 +32611,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32554,8 +32628,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32570,51 +32644,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32634,7 +32708,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32642,7 +32716,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32708,7 +32782,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32731,38 +32805,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -32809,20 +32883,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -32831,8 +32905,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -32841,58 +32915,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -32913,7 +32987,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -32931,39 +33005,39 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` } } @@ -32978,11 +33052,12 @@ var ts; var startPos = scanner.getStartPos(); var result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -32992,13 +33067,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33027,7 +33102,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33045,18 +33120,18 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) { + function parseEntityName(allowReservedWords, diagnosticMessage) { var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; } dotPos = getNodePos(); - entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos); + entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos); } return entity; } @@ -33089,12 +33164,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33105,7 +33180,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33123,7 +33198,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33131,13 +33206,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33152,30 +33227,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33189,11 +33264,11 @@ var ts; } // TYPES function parseEntityNameOfTypeReference() { - return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected); + return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33203,14 +33278,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33248,12 +33323,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33265,8 +33340,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33274,9 +33349,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*decorators*/ undefined, @@ -33290,15 +33365,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33307,13 +33382,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33321,9 +33396,10 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true); - var typeArguments = tryParseTypeArguments(); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); + var entityName = parseEntityName(/*allowReservedWords*/ true); + // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. + var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } function parseTypeParameter() { @@ -33332,7 +33408,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33351,21 +33427,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33389,7 +33465,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33405,7 +33481,7 @@ var ts; // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), @@ -33419,11 +33495,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33433,16 +33509,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33464,11 +33540,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33487,17 +33563,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33506,20 +33582,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33539,7 +33615,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33558,21 +33634,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(decorators, modifiers, parameters, type); @@ -33580,14 +33656,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33596,7 +33672,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33604,10 +33680,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33617,7 +33693,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33628,30 +33704,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33660,16 +33736,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33680,9 +33756,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33691,51 +33767,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33748,10 +33824,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -33760,10 +33836,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33772,21 +33848,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33795,10 +33871,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -33808,34 +33884,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -33844,89 +33920,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -33934,48 +34010,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -33985,18 +34061,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34004,15 +34080,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34028,9 +34104,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34044,17 +34120,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34083,7 +34159,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34097,35 +34173,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34135,7 +34211,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34143,17 +34219,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34174,65 +34250,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34243,19 +34319,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34273,10 +34349,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34289,10 +34365,10 @@ var ts; setDecoratorContext(/*val*/ false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos); + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -34300,9 +34376,9 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) { + function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -34328,7 +34404,7 @@ var ts; // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -34342,12 +34418,12 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then @@ -34356,13 +34432,13 @@ var ts; // Note: we call reScanGreaterToken so that we get an appropriately merged token // for cases like `> > =` becoming `>>=` if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } // It wasn't an assignment or a lambda. This is a conditional expression: return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34398,8 +34474,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher()), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34407,8 +34483,8 @@ var ts; return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, disallowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -34418,14 +34494,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34433,53 +34509,53 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? - parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) : - tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); }); + return triState === 1 /* Tristate.True */ ? + parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } // True -> We definitely expect a parenthesized arrow function here. // False -> There *cannot* be a parenthesized arrow function here. // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34488,102 +34564,102 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - return 1 /* True */; + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function parsePossibleParenthesizedArrowFunctionExpression() { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction); + var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, asyncModifier); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); } } return undefined; @@ -34592,26 +34668,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity, disallowReturnTypeInArrowFunction) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34621,7 +34697,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34638,28 +34714,11 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - // Given: - // x ? y => ({ y }) : z => ({ z }) - // We try to parse the body of the first arrow function by looking at: - // ({ y }) : z => ({ z }) - // This is a valid arrow function with "z" as the return type. - // - // But, if we're in the true side of a conditional expression, this colon - // terminates the expression, so we cannot allow a return type if we aren't - // certain whether or not the preceding text was parsed as a parameter list. - // - // For example, - // a() ? (b: number, c?: string): void => d() : e - // is determined by isParenthesizedArrowFunctionExpression to unambiguously - // be an arrow expression, so we allow a return type. - if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) { - return undefined; - } - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34674,31 +34733,31 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) : parseIdentifier(); var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync, disallowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + function parseArrowFunctionExpressionBody(isAsync) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34715,28 +34774,28 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }) - : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } function parseConditionalExpressionRest(leftOperand, pos) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher() + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -34744,7 +34803,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -34773,16 +34832,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -34803,7 +34862,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -34831,7 +34890,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -34864,7 +34923,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -34881,10 +34940,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -34909,23 +34968,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -34948,18 +35007,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -34980,17 +35039,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35031,29 +35090,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35115,19 +35174,19 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35135,11 +35194,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35165,11 +35224,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35180,11 +35239,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35194,13 +35253,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35214,15 +35273,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35232,14 +35291,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35251,21 +35310,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35273,8 +35332,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35295,60 +35354,60 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : - scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* SyntaxKind.EqualsToken */ ? undefined : + scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35361,11 +35420,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35378,36 +35437,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35428,8 +35487,8 @@ var ts; } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35438,7 +35497,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35449,30 +35508,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35487,14 +35546,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35503,7 +35562,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35511,9 +35570,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35526,7 +35585,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35534,22 +35593,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(31 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35562,58 +35621,34 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` - // These tokens can't follow in a call expression, nor can they start an - // expression. So, consider the type argument list part of an instantiation - // expression. - // falls through - case 27 /* CommaToken */: // foo, - case 24 /* DotToken */: // foo. - case 28 /* QuestionDotToken */: // foo?. - case 21 /* CloseParenToken */: // foo) - case 23 /* CloseBracketToken */: // foo] - case 58 /* ColonToken */: // foo: - case 26 /* SemicolonToken */: // foo; - case 57 /* QuestionToken */: // foo? - case 34 /* EqualsEqualsToken */: // foo == - case 36 /* EqualsEqualsEqualsToken */: // foo === - case 35 /* ExclamationEqualsToken */: // foo != - case 37 /* ExclamationEqualsEqualsToken */: // foo !== - case 55 /* AmpersandAmpersandToken */: // foo && - case 56 /* BarBarToken */: // foo || - case 60 /* QuestionQuestionToken */: // foo ?? - case 52 /* CaretToken */: // foo ^ - case 50 /* AmpersandToken */: // foo & - case 51 /* BarToken */: // foo | - case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; } - // Treat anything else as an expression. - return false; + // Consider something a type argument list only if the following token can't start an expression. + return !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35621,21 +35656,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35643,21 +35678,21 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); + var expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -35665,34 +35700,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { + var expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35701,18 +35736,18 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); - var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }) : undefined; + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); + var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful. node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); - var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); + parseExpected(58 /* SyntaxKind.ColonToken */); + var initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker @@ -35725,10 +35760,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35742,17 +35777,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -35763,20 +35798,20 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -35784,13 +35819,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -35803,9 +35838,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -35814,7 +35849,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -35826,58 +35861,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -35885,26 +35920,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { - var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); - parseExpected(21 /* CloseParenToken */); + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { + var expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35912,10 +35947,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35923,7 +35958,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -35931,47 +35966,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -35980,7 +36015,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36000,25 +36035,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36030,7 +36065,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36041,9 +36076,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36064,25 +36099,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36105,44 +36140,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36155,51 +36190,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36209,7 +36244,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36218,68 +36253,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36288,7 +36323,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -36311,16 +36346,16 @@ var ts; if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { var node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -36329,33 +36364,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36364,7 +36399,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36375,10 +36410,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* SyntaxKind.OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -36387,26 +36422,26 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36414,29 +36449,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36449,8 +36484,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36462,13 +36497,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36484,19 +36519,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36509,27 +36544,27 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36540,9 +36575,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); // Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker. node.typeParameters = typeParameters; @@ -36552,11 +36587,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36564,20 +36599,20 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); @@ -36585,21 +36620,21 @@ var ts; function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 173 /* SetAccessor */) + if (type && node.kind === 173 /* SyntaxKind.SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36616,7 +36651,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36626,24 +36661,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36657,7 +36692,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); } @@ -36672,7 +36707,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36685,7 +36720,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36702,17 +36737,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -36733,7 +36768,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -36741,33 +36776,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -36779,17 +36814,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36797,21 +36832,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -36819,17 +36854,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36845,45 +36880,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -36892,11 +36927,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36913,12 +36948,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -36929,9 +36964,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -36941,10 +36976,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36952,17 +36987,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -36973,37 +37008,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37013,7 +37048,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37021,7 +37056,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37035,15 +37070,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37052,21 +37087,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); - var value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37080,15 +37115,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -37106,26 +37141,26 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37141,8 +37176,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37155,17 +37190,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37190,10 +37225,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37228,15 +37263,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37256,26 +37291,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37287,13 +37322,13 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -37337,11 +37372,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37353,10 +37388,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37365,16 +37400,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); - var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); - while (token() === 80 /* PrivateIdentifier */) { + var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37382,9 +37417,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37394,9 +37429,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37444,7 +37479,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37457,16 +37492,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37474,35 +37509,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37510,10 +37545,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37532,7 +37567,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37561,26 +37596,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37588,14 +37623,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37603,7 +37638,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37652,7 +37687,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37690,7 +37725,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37705,31 +37740,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -37741,8 +37776,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37756,32 +37791,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -37798,7 +37833,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -37810,17 +37845,17 @@ var ts; // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false) + ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -37831,8 +37866,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -37860,35 +37895,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -37904,12 +37939,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -37920,12 +37955,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -37946,8 +37981,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -37969,14 +38004,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -37995,21 +38030,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38043,7 +38078,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38060,7 +38095,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38084,11 +38119,11 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38100,7 +38135,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38111,9 +38146,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38122,7 +38157,8 @@ var ts; if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + var end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -38137,18 +38173,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38156,26 +38192,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38183,15 +38219,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38203,7 +38239,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38211,9 +38247,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38230,7 +38266,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38245,7 +38281,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38258,16 +38294,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38275,7 +38311,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38292,7 +38328,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38447,9 +38483,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38704,7 +38740,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -38719,7 +38755,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -38757,7 +38793,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -38810,7 +38846,7 @@ var ts; })(IncrementalParser || (IncrementalParser = {})); /** @internal */ function isDeclarationFileName(fileName) { - return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]); + return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions); } ts.isDeclarationFileName = isDeclarationFileName; function parseResolutionMode(mode, pos, end, reportDiagnostic) { @@ -38937,18 +38973,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -38982,15 +39018,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39033,10 +39069,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39056,11 +39092,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39131,6 +39167,7 @@ var ts; ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -39363,18 +39400,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39383,7 +39420,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; var commandOptionsWithoutBuild = [ // CommandLine only options @@ -39466,7 +39503,7 @@ var ts; es2020: ts.ModuleKind.ES2020, es2022: ts.ModuleKind.ES2022, esnext: ts.ModuleKind.ESNext, - node12: ts.ModuleKind.Node12, + node16: ts.ModuleKind.Node16, nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -39641,15 +39678,15 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -39820,7 +39857,7 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, - node12: ts.ModuleResolutionKind.Node12, + node16: ts.ModuleResolutionKind.Node16, nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -40063,8 +40100,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, @@ -40296,7 +40333,7 @@ var ts; affectsModuleResolution: true, description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: ts.Diagnostics.Language_and_Environment, - defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; /* @internal */ @@ -40417,7 +40454,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40442,8 +40479,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40502,11 +40539,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40535,14 +40572,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40553,7 +40590,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -40888,7 +40925,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -40928,7 +40965,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -40995,16 +41032,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41019,16 +41056,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41045,7 +41082,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41237,10 +41274,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41291,19 +41328,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41312,25 +41349,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41385,7 +41422,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -41730,8 +41767,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -41972,11 +42009,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42120,7 +42157,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42154,13 +42191,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42183,7 +42220,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42261,7 +42298,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42318,7 +42355,8 @@ var ts; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; - Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; + Extensions[Extensions["TsOnly"] = 5] = "TsOnly"; })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -42328,7 +42366,7 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { var _a; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -42336,7 +42374,8 @@ var ts; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations: failedLookupLocations + failedLookupLocations: failedLookupLocations, + resolutionDiagnostics: diagnostics }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -42413,7 +42452,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42476,7 +42515,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -42531,13 +42570,24 @@ var ts; // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions }; + var diagnostics = []; + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -42556,7 +42606,7 @@ var ts; isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); @@ -42622,7 +42672,7 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getDefaultNodeResolutionFeatures(options) { - return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -42639,6 +42689,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ts.emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: ts.noop }; return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { @@ -42681,7 +42733,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -42832,7 +42884,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -42867,7 +42919,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -42980,8 +43032,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -43001,8 +43053,8 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ts.ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ts.ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ts.ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43014,10 +43066,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43220,7 +43272,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43236,15 +43288,15 @@ var ts; // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; - NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default"; + NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default"; NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault"; NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); - function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { - return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); } function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43263,15 +43315,34 @@ var ts; return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + var extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) + extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) + extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). + var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + var diagnostics = []; var state = { compilerOptions: compilerOptions, host: host, @@ -43279,10 +43350,12 @@ var ts; failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -43342,7 +43415,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43409,7 +43482,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43428,7 +43501,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43445,7 +43518,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43455,9 +43528,9 @@ var ts; } } function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) { var result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; + return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } @@ -43473,53 +43546,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: + case Extensions.TsOnly: + var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43578,6 +43653,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features: features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: ts.noop }; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); @@ -43664,6 +43741,8 @@ var ts; packageJsonInfoCache: packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: ts.noop }; var parts = ts.getPathComponents(fileName); parts.pop(); @@ -43727,6 +43806,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -43799,14 +43879,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; + case Extensions.TsOnly: + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -43843,7 +43925,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -43952,7 +44034,6 @@ var ts; function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { return loadModuleFromTargetImportOrExport; function loadModuleFromTargetImportOrExport(target, subpath, pattern) { - var _a, _b; if (typeof target === "string") { if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { if (state.traceEnabled) { @@ -43989,13 +44070,16 @@ var ts; } return toSearchResult(/*value*/ undefined); } - var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) + return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); } else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null if (!Array.isArray(target)) { - for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { - var key = _c[_i]; + for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) { + var key = _a[_i]; if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { var subTarget = target[key]; var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); @@ -44013,8 +44097,8 @@ var ts; } return toSearchResult(/*value*/ undefined); } - for (var _d = 0, target_2 = target; _d < target_2.length; _d++) { - var elem = target_2[_d]; + for (var _b = 0, target_2 = target; _b < target_2.length; _b++) { + var elem = target_2[_b]; var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); if (result) { return result; @@ -44032,6 +44116,128 @@ var ts; trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(/*value*/ undefined); + function toAbsolutePath(path) { + var _a, _b; + if (path === undefined) + return path; + return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a))); + } + function combineDirectoryPath(root, dir) { + return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir)); + } + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) { + var _a, _b, _c, _d; + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames }); + var commonSourceDirGuesses = []; + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory + var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts")); + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + var fragment = ts.ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + var parts = ts.getPathComponents(fragment); + parts.pop(); // remove a directory + var commonDir_1 = ts.getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir_1); + fragment = ts.ensureTrailingDirectorySeparator(commonDir_1); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(ts.createCompilerDiagnostic(isImports + ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath)); + } + for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) { + var commonSourceDirGuess = commonSourceDirGuesses_1[_i]; + var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) { + var candidateDir = candidateDirectories_1[_e]; + if (ts.startsWith(finalPath, candidateDir)) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator + var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; + for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { + var ext = jsAndDtsExtensions_1[_f]; + if (ts.fileExtensionIs(possibleInputBase, ext)) { + var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) { + var possibleExt = inputExts_1[_g]; + var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state))); + } + } + } + } + } + } + } + } + return undefined; + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) { + var _a, _b; + // Config file ouput paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess; + var candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } /* @internal */ @@ -44179,7 +44385,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44222,11 +44428,12 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -44269,9 +44476,10 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; /** @@ -44297,14 +44505,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44315,34 +44523,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44350,21 +44558,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44372,16 +44580,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -44401,7 +44609,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -44412,7 +44620,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -44486,8 +44694,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -44509,7 +44717,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -44536,7 +44744,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -44556,33 +44764,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -44608,36 +44816,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(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; @@ -44656,14 +44864,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -44690,11 +44898,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -44706,20 +44914,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -44739,7 +44947,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -44747,9 +44955,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -44762,7 +44970,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -44776,9 +44984,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -44802,11 +45010,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -44833,7 +45041,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -44866,21 +45074,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -44888,22 +45096,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -44911,21 +45119,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -44939,10 +45147,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -44952,8 +45160,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -44976,59 +45184,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45038,47 +45246,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45092,22 +45300,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45115,7 +45323,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45131,7 +45339,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45142,68 +45350,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45215,7 +45423,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45227,7 +45435,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45242,28 +45450,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45273,7 +45481,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45292,8 +45500,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45307,7 +45515,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45358,12 +45566,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45385,7 +45593,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -45402,7 +45610,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -45473,7 +45681,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -45507,7 +45715,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -45536,7 +45744,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -45555,9 +45763,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -45581,7 +45789,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -45590,12 +45798,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -45603,16 +45811,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -45620,7 +45828,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -45631,15 +45839,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -45649,14 +45857,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -45705,9 +45913,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -45724,7 +45932,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -45738,7 +45946,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -45749,10 +45957,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -45777,7 +45985,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -45805,7 +46013,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -45834,7 +46042,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -45846,28 +46054,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -45893,8 +46101,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -45932,76 +46140,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46018,9 +46226,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46034,46 +46242,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46100,17 +46308,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46118,25 +46326,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46144,8 +46352,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46155,10 +46363,10 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } @@ -46172,7 +46380,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */ || prop.name.kind !== 79 /* SyntaxKind.Identifier */) { continue; } var identifier = prop.name; @@ -46184,9 +46392,9 @@ 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 === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + var currentKind = prop.kind === 296 /* SyntaxKind.PropertyAssignment */ || prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || prop.kind === 169 /* SyntaxKind.MethodDeclaration */ + ? 1 /* ElementKind.Property */ + : 2 /* ElementKind.Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -46194,17 +46402,17 @@ var ts; } } } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46212,10 +46420,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46241,9 +46449,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46254,8 +46462,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46263,29 +46471,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46303,24 +46511,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46362,7 +46570,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46373,7 +46581,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -46412,10 +46620,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -46425,7 +46633,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -46441,7 +46649,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -46454,7 +46662,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -46512,11 +46720,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -46526,7 +46734,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -46574,7 +46782,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -46583,28 +46791,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -46616,28 +46824,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -46648,94 +46856,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -46745,73 +46953,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -46822,27 +47030,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -46862,28 +47070,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -46902,13 +47110,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -46919,15 +47127,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -46948,13 +47156,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -46966,11 +47174,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -46984,17 +47192,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47003,19 +47211,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47023,7 +47231,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47032,10 +47240,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47054,7 +47262,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47075,7 +47283,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47087,7 +47295,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47100,7 +47308,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47118,13 +47326,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47138,7 +47346,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47150,12 +47358,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47165,27 +47373,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -47204,7 +47412,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47219,7 +47427,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47264,12 +47472,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47285,7 +47493,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47298,19 +47506,19 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47322,72 +47530,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -47401,45 +47609,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -47453,9 +47661,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -47479,17 +47687,17 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } @@ -47574,32 +47782,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -47688,7 +47896,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -47822,24 +48030,24 @@ var ts; TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = new ts.Map(ts.getEntries({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ + string: 1 /* TypeFacts.TypeofEQString */, + number: 2 /* TypeFacts.TypeofEQNumber */, + bigint: 4 /* TypeFacts.TypeofEQBigInt */, + boolean: 8 /* TypeFacts.TypeofEQBoolean */, + symbol: 16 /* TypeFacts.TypeofEQSymbol */, + undefined: 65536 /* TypeFacts.EQUndefined */, + object: 32 /* TypeFacts.TypeofEQObject */, + function: 64 /* TypeFacts.TypeofEQFunction */ })); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -47945,10 +48153,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -47973,8 +48181,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -47989,7 +48197,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48023,7 +48231,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48037,20 +48245,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48102,10 +48310,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48200,7 +48408,7 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); @@ -48221,13 +48429,13 @@ var ts; getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48313,7 +48521,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48350,10 +48558,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -48424,32 +48632,32 @@ var ts; var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var nonInferrableAnyType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 65536 /* ObjectFlags.ContainsWideningType */); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -48459,27 +48667,28 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonInferrableType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48487,7 +48696,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48495,11 +48704,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -48647,7 +48856,7 @@ var ts; var enumRelation = new ts.Map(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -48658,7 +48867,7 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; @@ -48804,7 +49013,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -48818,44 +49027,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -48887,13 +49096,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -48901,7 +49110,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -48924,7 +49133,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -48933,8 +49142,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -48945,9 +49154,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -48990,7 +49199,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49032,7 +49241,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49041,7 +49250,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49056,9 +49265,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49091,7 +49300,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49101,17 +49310,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49131,8 +49340,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49146,7 +49355,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49160,17 +49369,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49184,7 +49393,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49200,19 +49409,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49227,9 +49436,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49257,7 +49466,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49272,7 +49481,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49295,19 +49504,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49332,7 +49541,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49347,30 +49556,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -49423,35 +49632,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -49466,17 +49675,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -49496,13 +49705,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -49511,12 +49720,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -49526,20 +49735,20 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -49554,7 +49763,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -49562,11 +49771,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -49582,39 +49791,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -49622,7 +49831,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -49631,7 +49840,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -49646,20 +49855,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -49667,7 +49876,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -49675,8 +49884,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -49701,7 +49910,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -49738,7 +49947,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -49765,7 +49974,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -49788,22 +49997,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -49815,10 +50024,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -49832,31 +50041,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -49869,7 +50078,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -49913,7 +50122,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -49925,10 +50134,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -49938,9 +50147,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -49959,9 +50168,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -49972,20 +50181,20 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50007,7 +50216,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50024,15 +50233,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50042,29 +50251,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50085,13 +50294,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50116,22 +50325,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { @@ -50145,7 +50354,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50158,7 +50367,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50170,14 +50379,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50187,7 +50396,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -50204,7 +50413,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50236,7 +50445,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50244,7 +50453,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50272,12 +50481,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50321,7 +50530,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50336,7 +50545,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50344,7 +50553,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50360,7 +50569,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50369,7 +50578,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -50378,7 +50587,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -50399,7 +50608,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -50416,7 +50625,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -50496,7 +50705,7 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -50508,7 +50717,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -50516,31 +50725,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -50551,38 +50760,38 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol) { var links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } return undefined; @@ -50625,7 +50834,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -50633,7 +50842,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -50644,7 +50853,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -50665,7 +50874,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -50688,22 +50897,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -50713,7 +50922,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -50734,9 +50943,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -50744,9 +50953,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -50780,7 +50989,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -50788,8 +50997,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -50803,8 +51012,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -50824,7 +51033,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -50845,7 +51054,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -50876,7 +51085,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -50936,7 +51145,7 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; @@ -50945,9 +51154,6 @@ var ts; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) { - error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -51000,7 +51206,7 @@ var ts; var tsExtension = ts.tryExtractTSExtension(moduleReference); var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 || moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -51011,27 +51217,27 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); var suggestedExt = (_h = suggestedExtensions.find(function (_a) { var actualExt = _a[0], _importExt = _a[1]; return host.fileExists(absoluteRef_1 + actualExt); })) === null || _h === void 0 ? void 0 : _h[1]; if (suggestedExt) { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -51063,27 +51269,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51097,7 +51303,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51116,12 +51322,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51153,7 +51359,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51205,15 +51411,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51228,7 +51434,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51263,7 +51469,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51352,21 +51558,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -51390,7 +51596,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -51411,7 +51617,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -51419,7 +51625,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -51429,7 +51635,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -51453,16 +51659,16 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol)); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && !getTypeOnlyAliasDeclaration(symbol)); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -51485,7 +51691,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -51499,7 +51705,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -51509,11 +51715,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -51545,14 +51751,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -51570,12 +51776,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -51584,9 +51790,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -51597,7 +51803,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -51616,7 +51822,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -51627,7 +51833,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -51671,9 +51877,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -51681,7 +51887,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -51725,7 +51931,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -51740,10 +51946,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -51754,16 +51960,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -51793,7 +51999,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -51817,14 +52023,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -51853,7 +52059,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -51862,28 +52068,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -51891,24 +52097,24 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + else if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement && ts.isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); @@ -51932,83 +52138,83 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52016,7 +52222,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52034,17 +52240,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 814775659 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52078,12 +52284,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52105,7 +52311,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52140,62 +52346,62 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52209,66 +52415,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52278,19 +52484,19 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52307,8 +52513,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52316,43 +52522,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52360,39 +52566,63 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); + var name = typeParameterToName(newParam, context); + var newTypeVariable = ts.factory.createTypeReferenceNode(name); + context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var saveInferTypeParameters_1 = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters_1; + var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive + // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType + // inner conditional runs the check the user provided on the check type (distributively) and returns the result + // checkType extends infer T ? T extends checkType ? T extends extendsType ? trueType : falseType : never : never; + // this is potentially simplifiable to + // checkType extends infer T ? T extends checkType & extendsType ? trueType : falseType : never; + // but that may confuse users who read the output more. + // On the other hand, + // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; + // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); + } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -52403,7 +52633,7 @@ var ts; return typeToTypeNodeHelper(type, context); } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -52411,27 +52641,27 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -52440,16 +52670,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */ && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -52458,7 +52688,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -52474,26 +52704,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -52505,7 +52735,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -52564,20 +52794,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -52586,8 +52816,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -52599,27 +52829,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -52627,7 +52857,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -52635,23 +52865,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -52675,8 +52905,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -52688,8 +52918,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -52753,17 +52983,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -52773,16 +53003,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -52793,10 +53023,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -52806,19 +53036,19 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; - if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { + if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* CheckFlags.Late */ && isLateBoundName(propertySymbol.escapedName)) { if (propertySymbol.declarations) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { @@ -52841,12 +53071,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -52860,12 +53090,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -52874,11 +53104,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -52897,12 +53127,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -52911,7 +53141,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -52936,7 +53166,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -52971,22 +53201,22 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -52994,7 +53224,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); var thisParameter = tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); @@ -53002,11 +53232,11 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53017,28 +53247,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53062,7 +53292,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53076,29 +53306,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */); - } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -53118,7 +53345,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53127,9 +53354,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53139,8 +53366,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53150,7 +53377,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -53169,8 +53396,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -53189,7 +53416,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53219,7 +53446,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53234,11 +53461,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53258,11 +53485,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53314,7 +53541,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53322,8 +53549,8 @@ var ts; return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier; } 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 - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53332,7 +53559,7 @@ var ts; var targetFile = ts.getSourceFileOfModule(chain[0]); var specifier = void 0; var assertion = void 0; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) { specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext); @@ -53344,9 +53571,9 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -53405,16 +53632,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -53433,7 +53660,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -53445,7 +53672,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -53458,9 +53685,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -53469,23 +53696,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -53502,7 +53729,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -53510,13 +53737,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -53528,38 +53755,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -53588,7 +53815,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -53598,8 +53825,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -53633,7 +53860,7 @@ var ts; return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -53645,7 +53872,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_6) { return result_6; @@ -53654,20 +53881,30 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; return result; } + function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { + var typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; + } + return false; + } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -53686,20 +53923,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -53717,17 +53954,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -53741,11 +53978,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -53762,16 +53999,16 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -53780,7 +54017,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -53795,17 +54032,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -53836,8 +54073,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -53850,10 +54087,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -53868,16 +54105,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -53894,7 +54131,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -53910,9 +54147,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54008,11 +54245,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54065,37 +54302,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54107,21 +54344,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54133,14 +54370,14 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -54166,7 +54403,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -54174,11 +54411,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -54191,20 +54428,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54213,18 +54450,18 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54237,7 +54474,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54251,23 +54488,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54283,14 +54520,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54301,10 +54538,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); @@ -54313,7 +54550,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54326,7 +54563,7 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); @@ -54334,7 +54571,7 @@ var ts; var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -54350,12 +54587,12 @@ var ts; })))]); addResult(ts.factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { addResult(ts.factory.createEnumDeclaration( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -54367,22 +54604,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -54416,7 +54653,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -54437,15 +54674,15 @@ var ts; var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -54494,7 +54731,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -54521,17 +54758,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -54574,15 +54811,15 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -54590,19 +54827,19 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -54613,7 +54850,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, @@ -54622,30 +54859,30 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -54653,21 +54890,21 @@ var ts; // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -54676,9 +54913,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -54686,16 +54923,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -54710,18 +54947,18 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -54736,7 +54973,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -54750,7 +54987,7 @@ var ts; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -54766,7 +55003,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -54781,17 +55018,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -54811,11 +55048,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -54826,25 +55063,25 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -54853,8 +55090,8 @@ var ts; /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); @@ -54863,19 +55100,19 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -54885,7 +55122,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -54894,7 +55131,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -54902,13 +55139,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -54929,7 +55166,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -54965,15 +55202,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -54983,22 +55220,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55016,7 +55253,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55025,17 +55262,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55054,14 +55291,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55071,10 +55308,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55086,25 +55323,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55112,27 +55349,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55144,9 +55381,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55160,9 +55397,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55175,17 +55412,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -55202,84 +55439,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55288,11 +55525,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55316,7 +55553,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55365,23 +55602,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -55398,12 +55635,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -55428,28 +55665,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -55457,9 +55694,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -55474,7 +55711,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -55489,15 +55726,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -55533,34 +55770,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -55571,18 +55808,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -55599,7 +55836,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -55607,7 +55844,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -55619,7 +55856,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -55633,9 +55870,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 32768 /* TypeFlags.Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -55646,11 +55883,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -55661,11 +55898,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -55687,11 +55924,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -55703,8 +55940,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -55722,7 +55959,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -55745,14 +55982,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -55781,7 +56018,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -55803,7 +56040,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -55863,7 +56100,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -55902,7 +56139,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -55932,12 +56169,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -55961,7 +56198,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56017,13 +56254,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56035,7 +56272,7 @@ var ts; var _a; var exportedMember = members_4.get(name); if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56068,9 +56305,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56082,16 +56319,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56111,7 +56348,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56129,7 +56366,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56139,11 +56376,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56153,7 +56390,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56161,18 +56398,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56186,7 +56423,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -56200,7 +56437,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56210,14 +56447,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56234,7 +56471,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56258,14 +56495,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56306,15 +56543,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56333,7 +56570,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56347,10 +56584,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -56373,7 +56610,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -56382,7 +56619,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -56407,11 +56644,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -56446,10 +56683,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -56464,8 +56701,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -56486,21 +56723,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -56508,13 +56745,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -56535,7 +56772,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -56556,7 +56793,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -56569,7 +56806,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -56578,7 +56815,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -56589,15 +56826,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -56605,56 +56842,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -56677,7 +56914,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -56688,46 +56925,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -56738,7 +56975,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -56751,9 +56988,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -56770,7 +57007,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -56781,10 +57018,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -56797,7 +57034,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -56820,7 +57057,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -56828,7 +57065,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -56837,13 +57074,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -56883,19 +57120,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -56905,7 +57142,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -56916,26 +57153,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -56960,7 +57197,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -56985,7 +57222,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -56993,15 +57230,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57041,8 +57278,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57050,8 +57287,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57065,7 +57302,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57079,8 +57316,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57101,7 +57338,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57120,7 +57357,7 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { @@ -57135,7 +57372,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57143,19 +57380,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57170,11 +57407,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -57183,23 +57420,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57211,15 +57448,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57245,22 +57482,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57272,22 +57509,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57313,7 +57550,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57329,14 +57566,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -57373,8 +57610,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -57383,7 +57620,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -57402,9 +57639,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -57429,10 +57666,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -57443,7 +57680,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -57452,7 +57689,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -57501,7 +57738,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -57510,10 +57747,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -57531,9 +57768,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -57559,10 +57796,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -57578,8 +57815,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -57589,7 +57826,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -57606,7 +57843,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -57614,7 +57851,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -57650,8 +57887,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -57686,7 +57923,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -57696,24 +57933,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -57725,7 +57962,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -57738,10 +57975,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -57749,11 +57986,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -57768,7 +58005,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -57931,12 +58168,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -57958,11 +58195,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -57987,8 +58224,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -57996,7 +58233,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58011,7 +58248,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58033,7 +58270,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58043,7 +58280,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58082,18 +58319,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58106,7 +58343,8 @@ var ts; if (symbol === globalThisSymbol) { var varsOnly_1 = new ts.Map(); members.forEach(function (p) { - if (!(p.flags & 418 /* BlockScoped */)) { + var _a; + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58115,10 +58353,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58134,8 +58372,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58144,16 +58382,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58171,20 +58409,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58205,11 +58443,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58219,29 +58457,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58261,7 +58499,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58289,13 +58527,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58308,12 +58546,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58321,7 +58559,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58331,8 +58569,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -58358,7 +58596,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -58366,8 +58604,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -58383,20 +58621,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -58404,34 +58642,34 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -58439,7 +58677,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -58448,7 +58686,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58472,7 +58710,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -58482,13 +58720,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -58507,7 +58745,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -58526,9 +58764,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -58589,7 +58827,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -58607,11 +58845,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -58621,7 +58859,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { hasDisjointDomainType = true; } } @@ -58633,7 +58871,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -58643,11 +58881,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -58672,7 +58910,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -58682,13 +58920,14 @@ var ts; // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of // nesting, so it is effectively just a safety stop. - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + var identity_1 = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) { + stack.push(identity_1); result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -58708,13 +58947,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -58734,23 +58973,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -58761,11 +59000,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -58824,7 +59063,7 @@ var ts; var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -58832,7 +59071,7 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !objectType.declaration.questionToken && !objectType.declaration.nameType); } @@ -58842,17 +59081,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ScriptTarget.ES2020 */) : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ScriptTarget.ES2015 */) : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -58867,21 +59106,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -58894,7 +59133,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -58912,41 +59151,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -58988,18 +59227,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59012,7 +59251,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59046,7 +59285,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59055,15 +59294,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59073,7 +59312,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59084,23 +59323,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59115,7 +59354,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59135,15 +59374,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -59186,13 +59425,13 @@ var ts; } function isApplicableIndexType(source, target) { // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index - // signature applies to types assignable to 'number' and numeric string literal types. + // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59243,17 +59482,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59268,7 +59507,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59286,7 +59525,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59335,7 +59574,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59347,7 +59586,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -59357,19 +59596,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -59381,25 +59620,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -59421,7 +59660,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -59430,7 +59669,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -59463,7 +59702,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -59475,18 +59714,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -59558,26 +59797,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -59604,7 +59843,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -59614,12 +59853,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -59628,7 +59867,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -59722,8 +59961,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -59737,7 +59976,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -59755,7 +59994,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -59770,8 +60009,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -59782,13 +60021,13 @@ var ts; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -59813,27 +60052,27 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -59858,10 +60097,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -59870,7 +60109,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -59898,7 +60137,7 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -59912,13 +60151,13 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; @@ -59940,7 +60179,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -59951,13 +60190,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -59992,14 +60231,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60030,12 +60269,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60070,9 +60309,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60084,21 +60323,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60120,10 +60359,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60131,14 +60370,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60154,7 +60393,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60165,22 +60404,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -60190,27 +60429,41 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); } } + // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the + // template type XXX, K has an added constraint of number | `${number}`. + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { + var mappedType = getTypeFromTypeNode(parent); + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + var typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + var constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = ts.append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60266,7 +60519,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60278,13 +60531,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60325,9 +60578,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60337,7 +60590,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -60348,13 +60601,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -60390,9 +60643,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -60457,7 +60710,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -60495,20 +60748,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -60517,14 +60770,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -60533,18 +60786,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -60553,28 +60806,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -60587,33 +60840,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -60631,7 +60884,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -60641,8 +60894,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -60650,8 +60903,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -60661,7 +60914,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -60679,26 +60932,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -60717,10 +60970,10 @@ var ts; var _loop_15 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -60735,7 +60988,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -60750,12 +61003,12 @@ var ts; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -60765,13 +61018,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -60823,19 +61076,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -60869,18 +61122,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -60894,20 +61147,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -60925,11 +61178,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -60943,7 +61196,7 @@ var ts; var _loop_16 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; @@ -60953,17 +61206,17 @@ var ts; } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -60982,7 +61235,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -60991,37 +61244,37 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; @@ -61045,11 +61298,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61058,8 +61311,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61096,20 +61349,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61120,41 +61373,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -61172,10 +61425,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -61188,10 +61441,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61205,11 +61458,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61226,7 +61479,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61238,7 +61491,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61247,7 +61500,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61276,12 +61529,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61310,37 +61563,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { + if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -61352,21 +61605,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -61378,8 +61631,8 @@ var ts; var constituents = getCrossProductIntersections(typeSet); // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions). - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -61390,12 +61643,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -61408,7 +61661,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -61416,7 +61669,7 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; @@ -61430,13 +61683,13 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -61468,7 +61721,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -61484,8 +61737,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -61505,12 +61758,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -61522,11 +61775,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -61536,14 +61789,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -61561,16 +61814,16 @@ var ts; function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) + return type.flags & 1048576 /* TypeFlags.Union */ ? isPossiblyReducibleByInstantiation(type) ? getIndexTypeForGenericType(type, stringsOnly) : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -61581,21 +61834,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -61612,7 +61865,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -61631,10 +61884,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -61645,13 +61898,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -61664,7 +61917,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -61677,35 +61930,35 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -61713,13 +61966,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -61740,16 +61993,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -61764,26 +62017,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -61793,7 +62046,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -61801,12 +62054,12 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -61818,33 +62071,33 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -61852,21 +62105,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -61888,20 +62141,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -61918,10 +62171,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -61939,62 +62192,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62019,7 +62272,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62033,17 +62286,20 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } } - // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where + // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P. + // For example, for an index access { [P in K]: Box }[X], we construct the type Box. + if (isGenericMappedType(objectType)) { + var nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + } } return type[cache] = type; } @@ -62053,19 +62309,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62075,7 +62331,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62083,12 +62339,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62099,33 +62355,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -62137,12 +62393,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -62158,11 +62414,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -62170,8 +62426,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -62181,7 +62437,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -62193,11 +62449,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62262,7 +62518,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62280,7 +62536,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62296,15 +62552,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -62322,7 +62578,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -62333,7 +62589,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -62361,14 +62617,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -62396,7 +62652,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -62419,7 +62675,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -62462,7 +62718,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -62475,7 +62731,7 @@ var ts; var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references @@ -62498,7 +62754,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -62512,7 +62768,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -62528,7 +62784,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -62541,7 +62797,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -62550,13 +62806,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -62576,13 +62832,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62591,7 +62847,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -62601,31 +62857,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -62635,7 +62891,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -62649,7 +62905,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -62664,11 +62920,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -62681,23 +62937,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62715,7 +62971,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -62726,39 +62982,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -62768,9 +63024,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -62786,20 +63042,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -62821,17 +63077,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -62847,99 +63103,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -62977,9 +63233,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -62988,22 +63244,22 @@ var ts; } } return type; - case 2 /* Function */: + case 2 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 3 /* TypeMapKind.Composite */: + case 4 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 3 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return { kind: 0 /* TypeMapKind.Simple */, source: source, target: target }; } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return { kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }; } function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + return { kind: 2 /* TypeMapKind.Function */, func: func }; } function makeCompositeTypeMapper(kind, mapper1, mapper2) { return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; @@ -63019,16 +63275,16 @@ var ts; return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(3 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63061,7 +63317,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63073,7 +63329,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63082,7 +63338,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63096,12 +63352,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63114,8 +63370,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -63136,8 +63392,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -63146,8 +63402,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -63156,7 +63412,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -63165,15 +63421,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -63184,9 +63440,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63208,11 +63464,11 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -63232,7 +63488,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63241,14 +63497,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63258,11 +63514,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63272,13 +63528,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63287,7 +63543,7 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; @@ -63312,7 +63568,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -63332,7 +63588,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -63345,62 +63601,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -63410,11 +63666,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -63424,15 +63680,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -63453,35 +63709,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -63495,17 +63751,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -63514,7 +63770,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -63524,13 +63780,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -63547,11 +63803,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -63589,7 +63845,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -63599,35 +63855,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -63651,7 +63907,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -63669,7 +63925,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -63686,7 +63942,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -63696,7 +63952,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -63713,7 +63969,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -63733,8 +63989,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -63758,7 +64014,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -63824,18 +64080,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -63860,7 +64116,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -63942,7 +64198,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -63952,7 +64208,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -63977,17 +64233,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64009,7 +64265,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64021,8 +64277,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64038,16 +64294,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64059,10 +64315,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64074,7 +64330,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64093,27 +64349,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* TypeFlags.Nullable */) === (getFalsyFlags(targetType) & 98304 /* TypeFlags.Nullable */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -64136,14 +64392,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -64158,21 +64414,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -64198,19 +64454,19 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64219,83 +64475,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; } return false; @@ -64311,38 +64567,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getReducedType(type) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) @@ -64371,19 +64627,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -64421,10 +64677,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -64469,24 +64725,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -64515,7 +64771,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -64528,7 +64784,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -64580,7 +64836,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperType && target !== markerSubType) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -64602,7 +64858,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -64650,7 +64906,7 @@ var ts; } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -64664,7 +64920,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -64673,19 +64929,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -64694,73 +64950,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -64779,10 +65035,10 @@ var ts; // // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. - if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -64792,10 +65048,9 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { - var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -64804,20 +65059,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -64836,25 +65091,22 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -64869,7 +65121,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -64877,19 +65129,19 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_19 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { @@ -64944,7 +65196,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -64967,28 +65219,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -64996,16 +65248,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65013,13 +65265,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65027,7 +65279,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65036,19 +65288,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65056,50 +65308,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65110,54 +65362,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65171,28 +65423,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); } - if (saved & 16 /* ReportsUnreliable */) { + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65208,42 +65460,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65251,30 +65503,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -65283,14 +65535,14 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; @@ -65300,29 +65552,29 @@ var ts; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -65330,18 +65582,18 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { + if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -65355,10 +65607,10 @@ var ts; // needs to have its constraint hoisted into an intersection with said type parameter, this way // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65370,20 +65622,20 @@ var ts; // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -65392,34 +65644,34 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65432,8 +65684,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -65448,7 +65700,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -65456,18 +65708,18 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65485,14 +65737,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -65511,12 +65763,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -65524,22 +65776,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65559,7 +65811,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -65569,12 +65821,12 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -65585,8 +65837,8 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { resetErrorInfo(saveErrorInfo); return result; @@ -65594,37 +65846,37 @@ var ts; } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source); - if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) { + if (!constraint || (sourceFlags & 262144 /* TypeFlags.TypeParameter */ && constraint.flags & 1 /* TypeFlags.Any */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* TypeFlags.NonPrimitive */), 3 /* RecursionFlags.Both */)) { resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65633,7 +65885,7 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65641,44 +65893,44 @@ var ts; } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */ && source.symbol === target.symbol) { + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -65687,15 +65939,15 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65708,7 +65960,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65718,7 +65970,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65727,7 +65979,7 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -65736,22 +65988,22 @@ var ts; return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -65761,41 +66013,41 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -65812,9 +66064,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -65822,7 +66074,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -65832,7 +66084,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -65859,8 +66111,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -65892,14 +66144,14 @@ var ts; var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -65914,7 +66166,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -65926,8 +66178,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -65936,7 +66188,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -65957,7 +66209,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -65974,7 +66226,7 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { @@ -65984,20 +66236,20 @@ var ts; return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66024,40 +66276,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66067,7 +66319,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66075,10 +66327,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -66089,7 +66341,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -66100,7 +66352,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -66142,29 +66394,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -66175,38 +66427,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66214,12 +66466,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66229,14 +66481,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66245,18 +66497,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -66268,12 +66520,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66282,24 +66534,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66311,17 +66563,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -66330,18 +66582,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -66349,7 +66601,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66364,10 +66616,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -66393,18 +66645,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -66427,45 +66679,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66475,7 +66727,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66483,7 +66735,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -66500,14 +66752,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66518,46 +66770,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -66570,19 +66822,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -66591,7 +66843,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -66611,7 +66863,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -66646,12 +66898,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -66667,7 +66919,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -66683,14 +66935,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; var _loop_22 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -66701,22 +66953,22 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } @@ -66737,7 +66989,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -66748,34 +67000,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -66783,7 +67035,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -66819,12 +67071,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -66839,7 +67091,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } // Return the inherited type of the given property or undefined if property doesn't exist in a base class. function getTypeOfPropertyInBaseClass(property) { @@ -66857,13 +67109,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -66881,12 +67133,12 @@ var ts; function isDeeplyNestedType(type, stack, depth, maxDepth) { if (maxDepth === void 0) { maxDepth = 3; } if (depth >= maxDepth) { - var identity_1 = getRecursionIdentity(type); + var identity_2 = getRecursionIdentity(type); var count = 0; var lastTypeId = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (getRecursionIdentity(t) === identity_1) { + if (getRecursionIdentity(t) === identity_2) { // We only count occurrences with a higher type id than the previous occurrence, since higher // type ids are an indicator of newer instantiations caused by recursion. if (t.id >= lastTypeId) { @@ -66909,14 +67161,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -66926,49 +67178,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -66999,14 +67251,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67017,12 +67269,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67030,7 +67282,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67042,7 +67294,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67056,10 +67308,10 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -67090,20 +67342,23 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : - getUnionType(types, 2 /* Subtype */); + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* TypeFlags.Nullable */) : + getUnionType(types, 2 /* UnionReduction.Subtype */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; + } + function isArrayOrTupleType(type) { + return isArrayType(type) || isTupleType(type); } function isMutableArrayOrTuple(type) { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; @@ -67114,22 +67369,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -67144,7 +67399,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -67171,44 +67426,44 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getBaseTypeOfLiteralType) : type; } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67239,10 +67494,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -67263,7 +67518,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -67271,7 +67526,7 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; @@ -67289,31 +67544,31 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 : - type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 : - type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 : - type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 : - type.flags & 117724 /* PossiblyFalsy */; + return type.flags & 1048576 /* TypeFlags.Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value === "" ? 128 /* TypeFlags.StringLiteral */ : 0 : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? type.value === 0 ? 256 /* TypeFlags.NumberLiteral */ : 0 : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* TypeFlags.BigIntLiteral */ : 0 : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* TypeFlags.BooleanLiteral */ : 0 : + type.flags & 117724 /* TypeFlags.PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* TypeFlags.DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* TypeFlags.DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -67322,24 +67577,24 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' // that isn't eliminated by a NonNullable instantiation. - var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + var reducedType = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? @@ -67367,10 +67622,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -67393,23 +67648,23 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -67439,7 +67694,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -67450,7 +67705,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -67480,7 +67735,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -67492,7 +67747,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -67508,7 +67763,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -67527,36 +67782,36 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -67579,8 +67834,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -67593,7 +67848,7 @@ var ts; } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { @@ -67605,7 +67860,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -67624,17 +67879,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -67645,25 +67900,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -67672,10 +67927,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -67687,7 +67942,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -67790,9 +68045,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -67838,40 +68093,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? false : "quit"; })); } return false; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || - type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -67879,7 +68134,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -67907,7 +68162,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -67924,14 +68179,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -67966,7 +68221,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -67976,9 +68231,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -67996,7 +68251,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68007,7 +68262,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68029,12 +68284,12 @@ var ts; sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); } function isValidBigIntString(s) { - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - if (result === 40 /* MinusToken */) { + if (result === 40 /* SyntaxKind.MinusToken */) { result = scanner.scan(); } var flags = scanner.getTokenFlags(); @@ -68043,27 +68298,27 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */); } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || - target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + return !!(target.flags & 8 /* TypeFlags.Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* TypeFlags.BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -68073,7 +68328,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -68155,12 +68410,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -68182,7 +68437,7 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -68191,10 +68446,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68209,21 +68464,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -68231,10 +68486,10 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -68242,12 +68497,12 @@ var ts; // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* InferencePriority.ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -68272,7 +68527,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -68285,11 +68540,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -68297,45 +68552,45 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); contravariant = !contravariant; } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); var oldPriority = priority; - priority |= 4 /* SubstituteSource */; + priority |= 4 /* InferencePriority.SubstituteSource */; inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority priority = oldPriority; } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -68343,17 +68598,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -68366,7 +68621,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -68384,19 +68639,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -68404,7 +68659,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -68432,7 +68687,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -68441,7 +68696,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -68451,7 +68706,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -68465,7 +68720,7 @@ var ts; var typeVariable; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -68475,9 +68730,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -68493,11 +68748,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -68508,7 +68763,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -68542,17 +68797,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -68560,7 +68815,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -68572,17 +68827,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -68601,7 +68856,7 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); @@ -68609,7 +68864,7 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; @@ -68631,7 +68886,7 @@ var ts; } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -68646,7 +68901,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -68654,7 +68909,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); @@ -68669,21 +68924,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -68692,14 +68947,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -68719,8 +68974,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -68740,7 +68995,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -68748,9 +69003,9 @@ var ts; function inferFromSignature(source, target, skipParameters) { if (!skipParameters) { var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -68758,7 +69013,7 @@ var ts; } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -68766,9 +69021,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -68793,34 +69048,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -68837,8 +69092,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -68852,14 +69107,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -68880,7 +69135,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -68950,7 +69205,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -68962,7 +69217,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -68971,7 +69226,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -68979,22 +69234,22 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -69005,44 +69260,44 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -69063,15 +69318,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -69110,12 +69365,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -69145,7 +69400,7 @@ var ts; var map = new ts.Map(); var count = 0; var _loop_23 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -69181,15 +69436,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -69213,7 +69468,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -69230,7 +69485,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -69244,7 +69499,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69260,11 +69515,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { + if (assignedType.flags & 131072 /* TypeFlags.Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { + if (assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType)) { reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types } // Our crude heuristic produces an invalid result in some cases: see GH#26130. @@ -69287,93 +69542,93 @@ var ts; function getTypeFacts(type, ignoreObjects) { if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; - if (flags & 4 /* String */) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & 4 /* TypeFlags.String */) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & 128 /* StringLiteral */) { + if (flags & 128 /* TypeFlags.StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { if (ignoreObjects) { - return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection. + return 16768959 /* TypeFacts.AndFactsMask */; // This is the identity element for computing type facts of intersection. } - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 16318463 /* TypeFacts.EmptyObjectStrictFacts */ : 16777215 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { - return 9830144 /* UndefinedFacts */; + if (flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { + return 9830144 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 9363232 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 9363232 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 465829888 /* Instantiable */) { + if (flags & 465829888 /* TypeFlags.Instantiable */) { return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : - strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; + strictNullChecks ? 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */)); return getIntersectionTypeFacts(type, ignoreObjects); } - return 16777215 /* All */; + return 16777215 /* TypeFacts.All */; } function getIntersectionTypeFacts(type, ignoreObjects) { // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 16777215 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 16777215 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; var f = getTypeFacts(t, ignoreObjects); oredFacts |= f; andedFacts &= f; } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 16768959 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -69393,7 +69648,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -69404,18 +69659,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -69432,21 +69687,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -69454,7 +69709,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -69472,37 +69727,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -69510,13 +69765,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -69536,7 +69791,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -69549,13 +69804,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -69564,25 +69819,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -69590,45 +69845,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -69639,11 +69894,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -69655,13 +69910,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -69673,14 +69928,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -69695,10 +69950,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -69706,17 +69961,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { var t = types_18[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -69730,16 +69985,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -69748,11 +70003,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -69763,11 +70018,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -69782,16 +70037,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -69809,7 +70064,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -69823,10 +70078,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -69834,7 +70089,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -69844,10 +70099,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -69867,8 +70122,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -69876,7 +70131,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -69884,30 +70139,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -69915,7 +70170,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -69923,7 +70178,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -69934,7 +70189,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -69943,7 +70198,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -69951,24 +70206,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -69978,18 +70233,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -70015,8 +70270,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -70032,7 +70287,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -70041,7 +70296,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -70054,56 +70309,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -70127,7 +70382,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -70139,7 +70394,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -70150,7 +70405,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -70167,14 +70422,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -70182,14 +70437,14 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -70199,15 +70454,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : - predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -70216,15 +70471,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -70233,7 +70488,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -70247,7 +70502,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -70257,7 +70512,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -70272,16 +70527,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -70298,7 +70553,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -70342,7 +70597,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -70368,7 +70623,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -70421,7 +70676,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -70436,7 +70691,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -70482,8 +70737,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -70499,8 +70754,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -70508,16 +70763,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -70526,7 +70781,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -70537,52 +70792,52 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType : - getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return type.flags & 2 /* TypeFlags.Unknown */ && assumeTrue ? nonNullUnknownType : + getTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -70614,35 +70869,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -70675,48 +70930,48 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) { + if (assumeTrue && (type.flags & 2 /* TypeFlags.Unknown */) && (operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */) && (valueType.flags & 65536 /* TypeFlags.Null */)) { return getUnionType([nullType, undefinedType]); } - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; - return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; + return type.flags & 2 /* TypeFlags.Unknown */ && facts & (1048576 /* TypeFacts.NENull */ | 2097152 /* TypeFacts.NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -70728,34 +70983,34 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } - if (type.flags & 1 /* Any */ && literal.text === "function") { + if (type.flags & 1 /* TypeFlags.Any */ && literal.text === "function") { return type; } - if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { + if (assumeTrue && type.flags & 2 /* TypeFlags.Unknown */ && literal.text === "object") { // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null // unknown type, and then narrows that to the non-primitive type. return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeFacts.TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */; var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text); return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -70768,16 +71023,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -70790,20 +71045,20 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { switch (text) { case "function": - return type.flags & 1 /* Any */ ? type : globalFunctionType; + return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType; case "object": - return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; default: return typeofTypesByName.get(text); } @@ -70822,7 +71077,7 @@ var ts; if (isTypeSubtypeOf(candidate, type)) { return candidate; } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(candidate, constraint)) { return getIntersectionType([type, candidate]); @@ -70897,7 +71152,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -70927,8 +71182,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -70939,7 +71194,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -70962,13 +71217,13 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; @@ -70981,9 +71236,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { + if (!(assignableType.flags & 131072 /* TypeFlags.Never */)) { return assignableType; } } @@ -71001,7 +71256,7 @@ var ts; if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71011,7 +71266,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71026,8 +71281,8 @@ var ts; return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { @@ -71042,11 +71297,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -71062,20 +71317,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -71084,11 +71339,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -71099,7 +71354,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -71123,9 +71378,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -71135,8 +71390,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -71145,11 +71400,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -71162,18 +71417,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 32768 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -71185,17 +71440,17 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -71204,8 +71459,8 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) : getContextualType(node)); return contextualType && !isGenericType(contextualType); } @@ -71217,10 +71472,10 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); - return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (n) { @@ -71238,9 +71493,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -71283,16 +71538,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { - var links = getNodeLinks(location); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { + var links = getNodeLinks(parent); + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -71326,7 +71581,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -71357,15 +71612,15 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } // We should only mark aliases as referenced if there isn't a local value declaration @@ -71379,32 +71634,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -71416,19 +71671,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -71437,11 +71692,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -71458,17 +71713,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -71476,11 +71731,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -71497,7 +71752,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -71514,11 +71769,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -71533,12 +71788,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -71548,22 +71803,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -71573,7 +71828,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -71581,9 +71836,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -71593,13 +71848,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -71641,36 +71896,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -71705,7 +71960,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -71753,9 +72008,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -71763,31 +72018,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -71799,17 +72054,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -71819,18 +72074,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -71841,14 +72096,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -71856,26 +72111,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -71937,12 +72192,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -71951,8 +72206,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -71972,12 +72227,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -71987,7 +72242,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -71995,23 +72250,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72019,22 +72274,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -72061,7 +72316,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -72075,7 +72330,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -72103,7 +72358,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -72128,11 +72383,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -72143,10 +72398,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -72179,7 +72434,7 @@ var ts; if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } @@ -72191,8 +72446,8 @@ var ts; var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var use = functionFlags & 2 /* FunctionFlags.Async */ ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); if (!iterationTypes) { return undefined; @@ -72200,7 +72455,7 @@ var ts; contextualReturnType = iterationTypes.returnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72226,7 +72481,7 @@ var ts; if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); } } return undefined; @@ -72245,7 +72500,7 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); var contextualReturnType = getContextualReturnType(functionDecl); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) @@ -72292,11 +72547,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -72305,13 +72560,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -72320,8 +72575,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -72354,8 +72609,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -72365,11 +72620,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (decl.initializer && getTypeOfExpression(binaryExpression.left)); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -72390,7 +72645,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -72404,18 +72659,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -72423,14 +72678,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -72454,7 +72709,7 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { @@ -72467,7 +72722,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -72488,7 +72743,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72523,7 +72778,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -72578,29 +72833,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -72609,24 +72864,24 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. - if (contextFlags && contextFlags & 1 /* Signature */) { + if (contextFlags && contextFlags & 1 /* ContextFlags.Signature */) { return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); } // For other purposes (e.g. determining whether to produce literal types) we only @@ -72635,7 +72890,7 @@ var ts; // literals actually end up widening to 'boolean' (see #48363). if (inferenceContext.returnMapper) { var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -72647,13 +72902,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -72676,7 +72931,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72685,60 +72940,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -72751,7 +73006,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -72760,7 +73015,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -72805,7 +73060,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -72820,7 +73075,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -72921,12 +73176,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -72948,18 +73203,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -72989,16 +73244,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -73027,18 +73282,18 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -73051,14 +73306,14 @@ var ts; var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -73074,27 +73329,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -73108,28 +73363,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -73138,14 +73393,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -73156,17 +73411,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -73182,7 +73437,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -73194,11 +73449,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -73218,9 +73473,9 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -73242,16 +73497,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -73263,29 +73518,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -73300,17 +73555,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -73344,10 +73599,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -73372,11 +73627,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -73408,12 +73663,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -73423,8 +73678,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -73470,7 +73725,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -73494,15 +73749,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -73517,7 +73772,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -73533,6 +73788,7 @@ var ts; } } else { + error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -73543,7 +73799,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -73557,7 +73813,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -73585,7 +73841,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -73595,12 +73851,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -73612,7 +73868,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -73632,7 +73888,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -73651,13 +73907,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -73706,10 +73962,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -73722,7 +73978,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -73737,7 +73993,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -73761,7 +74017,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -73775,10 +74031,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -73791,12 +74047,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -73824,13 +74080,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -73861,10 +74117,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -73898,7 +74154,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -73916,20 +74172,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -73938,7 +74194,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -73963,7 +74219,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -73975,7 +74231,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -73986,10 +74242,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -74012,13 +74268,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -74032,9 +74288,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -74057,7 +74313,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -74065,7 +74321,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -74077,7 +74333,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -74088,12 +74344,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -74120,7 +74376,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -74128,10 +74384,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -74146,10 +74402,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -74159,39 +74415,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */; if (kind) { reportError(node, kind); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -74200,13 +74456,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -74219,7 +74475,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -74243,7 +74499,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -74315,16 +74571,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -74346,8 +74602,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -74363,15 +74619,20 @@ var ts; prop = getPropertyOfType(apparentType, right.escapedText); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined + // here even if `Foo` is not a const enum. + // // The exceptions are: // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. - if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -74379,7 +74640,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -74399,7 +74660,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -74411,7 +74672,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -74430,11 +74691,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -74444,12 +74705,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -74462,12 +74723,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -74480,7 +74741,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; @@ -74498,13 +74759,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -74515,25 +74776,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -74545,7 +74806,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -74570,7 +74831,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -74658,7 +74919,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -74669,7 +74930,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -74677,7 +74938,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -74696,7 +74957,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -74712,7 +74973,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -74743,7 +75004,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -74771,7 +75032,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -74781,16 +75042,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -74800,19 +75061,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -74827,7 +75088,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -74867,13 +75128,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -74890,13 +75151,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -74910,7 +75171,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -74919,7 +75180,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -74931,8 +75192,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -74945,13 +75206,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -75015,16 +75276,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -75032,9 +75293,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -75045,11 +75306,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -75063,7 +75324,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -75087,7 +75348,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -75103,20 +75364,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -75125,12 +75386,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -75138,7 +75399,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -75166,8 +75427,8 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { - var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); + if (node.kind !== 165 /* SyntaxKind.Decorator */) { + var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { @@ -75175,7 +75436,7 @@ var ts; // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. var outerContext = getInferenceContext(node); - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -75189,7 +75450,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of // the source type uses the outer context's return mapper (which excludes inferences made from @@ -75203,7 +75464,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -75216,7 +75477,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -75231,10 +75492,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -75242,7 +75503,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -75252,24 +75513,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -75299,16 +75560,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -75333,7 +75594,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -75341,12 +75602,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -75356,7 +75617,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -75413,7 +75674,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -75431,13 +75692,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -75476,8 +75737,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -75495,17 +75756,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -75519,12 +75780,12 @@ var ts; var _loop_24 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -75546,30 +75807,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -75583,17 +75844,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -75627,7 +75888,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -75669,8 +75930,14 @@ var ts; var parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && ts.isInJSFile(node)) { + return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + var error = hasRestParameter + ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : ts.Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { // between min and max, but with no matching overload @@ -75729,15 +75996,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -75764,7 +76031,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -75792,7 +76060,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -75825,7 +76093,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -75848,7 +76116,7 @@ var ts; var i_1 = 0; var _loop_25 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -75933,7 +76201,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -75956,9 +76224,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -75980,7 +76248,7 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = 0 /* Normal */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -76033,14 +76301,14 @@ var ts; _loop_26(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -76053,7 +76321,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -76090,8 +76358,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -76111,7 +76379,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -76126,7 +76394,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -76135,13 +76403,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -76156,8 +76424,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -76184,7 +76452,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -76200,7 +76468,7 @@ var ts; // use the resolvingSignature singleton to indicate that we deferred processing. This result will be // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -76221,11 +76489,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -76258,7 +76526,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -76267,24 +76535,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -76295,14 +76563,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -76310,7 +76578,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -76318,7 +76586,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -76341,9 +76609,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -76351,16 +76619,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -76369,10 +76637,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { @@ -76422,7 +76690,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -76466,8 +76734,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76477,26 +76745,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -76511,8 +76779,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76523,38 +76791,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -76575,7 +76843,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -76591,16 +76859,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -76623,7 +76891,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -76664,7 +76932,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -76700,16 +76968,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -76732,10 +77000,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -76755,15 +77023,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -76780,11 +77048,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -76797,14 +77065,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -76813,20 +77081,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -76848,7 +77116,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -76863,13 +77131,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -76885,11 +77153,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + newSymbol.aliasTarget = resolveSymbol(symbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -76912,7 +77180,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -76932,40 +77200,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -76973,31 +77241,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -77028,12 +77296,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -77058,7 +77326,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -77066,12 +77334,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -77080,10 +77348,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -77099,19 +77367,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -77124,7 +77392,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -77134,16 +77402,16 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -77176,7 +77444,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77208,7 +77476,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77258,11 +77526,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -77286,14 +77554,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -77301,7 +77569,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -77311,7 +77579,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -77341,7 +77609,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -77361,7 +77629,7 @@ var ts; } } var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { // The contextual signature has a generic rest parameter. We first instantiate the contextual // signature (without fixing type parameters) and assign types to contextually typed parameters. var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); @@ -77405,7 +77673,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -77425,7 +77693,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -77444,7 +77712,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -77492,8 +77760,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -77505,14 +77773,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -77527,36 +77795,36 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { @@ -77565,9 +77833,9 @@ var ts; contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -77581,7 +77849,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -77624,13 +77892,13 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { @@ -77644,7 +77912,7 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -77656,14 +77924,14 @@ var ts; * whether the active clause contains a default clause. */ function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; // When in the default we only collect inequality facts // because default is 'in theory' a set of infinite // equalities. if (hasDefault) { // Value is not equal to any types after the active clause. for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -77673,7 +77941,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -77681,7 +77949,7 @@ var ts; else { // Add equalities for all types in the active clause. for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeFacts.TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -77696,17 +77964,17 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); var type_6 = getBaseConstraintOfType(operandType) || operandType; // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types. - if (type_6.flags & 3 /* AnyOrUnknown */) { - return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */; + if (type_6.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_1) === 556800 /* TypeFacts.AllTypeofNE */; } - return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* TypeFlags.Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -77730,15 +77998,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -77759,11 +78027,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -77784,17 +78052,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -77823,13 +78091,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -77840,9 +78108,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -77850,7 +78118,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -77859,21 +78127,21 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); } var instantiatedContextualSignature = inferenceContext ? @@ -77896,7 +78164,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -77909,7 +78177,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -77921,7 +78189,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -77979,27 +78247,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -78020,11 +78288,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -78032,12 +78300,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -78066,8 +78334,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -78085,21 +78353,36 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = void 0; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -78109,7 +78392,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -78125,7 +78408,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -78136,16 +78419,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -78153,28 +78436,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -78197,8 +78480,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -78218,7 +78501,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var t = types_21[_i]; @@ -78233,30 +78516,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -78268,7 +78551,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -78282,8 +78565,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -78296,8 +78579,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -78322,9 +78605,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -78344,7 +78627,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -78355,17 +78638,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -78387,18 +78670,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -78407,15 +78690,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -78426,7 +78709,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -78442,14 +78725,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* TypeFlags.Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -78458,31 +78741,31 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -78497,59 +78780,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -78580,9 +78863,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -78599,8 +78882,8 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var parent = ts.walkUpParenthesizedExpressions(node.parent); checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } @@ -78660,11 +78943,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -78673,11 +78956,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -78689,28 +78972,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -78719,8 +79002,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -78731,21 +79014,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -78761,26 +79044,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -78798,21 +79081,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -78821,56 +79104,56 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -78880,7 +79163,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -78898,16 +79181,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -78917,12 +79200,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -78932,15 +79215,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -78959,7 +79242,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -78973,13 +79256,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -79022,12 +79305,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -79053,20 +79336,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -79083,15 +79366,15 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { @@ -79105,7 +79388,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -79118,7 +79401,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -79131,7 +79414,7 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); @@ -79140,11 +79423,11 @@ var ts; return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -79156,7 +79439,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -79165,7 +79448,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -79178,7 +79461,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -79198,17 +79481,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -79218,9 +79501,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -79229,7 +79512,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -79244,28 +79527,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -79286,7 +79569,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -79297,23 +79580,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -79361,11 +79644,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -79395,7 +79678,7 @@ var ts; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -79420,7 +79703,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -79453,7 +79736,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -79465,7 +79748,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -79480,7 +79763,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -79490,8 +79773,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -79511,7 +79794,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -79522,7 +79805,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -79540,18 +79823,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -79569,113 +79852,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -79700,19 +79983,28 @@ var ts; if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) { + checkNodeDeferred(node); + addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); + } + function checkTypeParameterDeferred(node) { + if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) { + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); var modifiers = getVarianceModifiers(typeParameter); - if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + if (modifiers) { var symbol = getSymbolOfNode(node.parent); - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); - var saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { + error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubType : markerSuperType); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperType : markerSubType); + var saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); } function checkParameter(node) { // Grammar checking @@ -79722,11 +80014,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -79737,13 +80029,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -79767,7 +80059,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -79801,13 +80093,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -79821,11 +80113,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -79834,29 +80126,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -79872,17 +80164,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -79894,18 +80186,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -79917,11 +80209,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -79932,24 +80224,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -79959,19 +80251,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -80020,15 +80312,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -80045,7 +80337,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -80093,7 +80385,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -80110,7 +80402,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -80120,9 +80412,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -80130,8 +80422,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -80163,7 +80455,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -80184,9 +80476,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -80202,7 +80494,7 @@ var ts; superCallStatement = statement; break; } - if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -80225,7 +80517,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -80243,9 +80535,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -80253,25 +80545,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -80283,7 +80575,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -80315,15 +80607,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -80339,10 +80631,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -80381,29 +80673,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -80423,15 +80715,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -80439,14 +80731,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -80495,7 +80787,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -80505,7 +80797,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -80532,8 +80824,8 @@ var ts; if (node.assertions) { var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -80543,31 +80835,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -80592,16 +80884,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -80618,8 +80910,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -80628,7 +80920,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -80657,7 +80949,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -80682,7 +80974,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -80698,8 +80990,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -80710,10 +81002,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -80757,13 +81049,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -80773,7 +81065,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -80813,15 +81105,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -80854,56 +81146,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -80939,32 +81231,32 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -80984,16 +81276,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -81003,7 +81295,7 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } @@ -81027,7 +81319,7 @@ var ts; var baseConstraint = getBaseConstraintOfType(type); // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { + if (!baseConstraint || (baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { // Nothing to do if `Awaited` doesn't exist var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); if (awaitedSymbol) { @@ -81073,7 +81365,7 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); } @@ -81190,7 +81482,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -81213,10 +81505,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -81236,7 +81528,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -81249,26 +81541,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -81290,9 +81582,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -81327,15 +81619,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -81344,13 +81636,13 @@ var ts; var commonEntityName; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -81395,15 +81687,15 @@ var ts; error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } var firstDecorator = node.decorators[0]; - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -81412,23 +81704,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -81518,9 +81810,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -81534,7 +81826,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -81550,7 +81842,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -81560,7 +81852,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -81578,7 +81870,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -81606,42 +81898,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -81652,41 +81944,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -81697,7 +81989,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -81714,7 +82006,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -81726,17 +82018,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -81773,7 +82065,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -81804,7 +82096,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -81820,10 +82112,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -81836,9 +82128,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -81857,38 +82149,38 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -81905,7 +82197,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -81923,17 +82215,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -81953,8 +82245,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -81968,8 +82260,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -81983,53 +82275,53 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -82040,7 +82332,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -82048,13 +82340,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -82072,7 +82364,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -82104,35 +82396,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -82163,23 +82455,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } if (ts.isBindingElement(node)) { - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -82189,15 +82481,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -82208,7 +82500,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -82225,7 +82517,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -82236,7 +82528,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -82250,7 +82542,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -82266,7 +82558,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (node.initializer) { @@ -82276,10 +82568,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -82287,7 +82579,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -82297,24 +82589,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -82340,7 +82632,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -82349,13 +82641,13 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) @@ -82369,7 +82661,7 @@ var ts; // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -82409,7 +82701,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -82433,7 +82725,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -82463,7 +82755,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -82474,12 +82766,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -82504,29 +82796,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -82558,7 +82850,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -82572,7 +82864,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -82585,7 +82877,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -82602,7 +82894,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -82617,14 +82909,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -82633,10 +82925,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -82653,22 +82945,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -82676,7 +82968,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -82688,7 +82980,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -82697,12 +82989,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -82710,9 +83002,9 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { - return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; @@ -82759,9 +83051,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -82831,17 +83123,17 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } return undefined; } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; @@ -82851,7 +83143,7 @@ var ts; var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; @@ -82890,20 +83182,20 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? + return use & 8 /* IterationUse.ForOfFlag */ ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { // for a sync iterable in an async context, only use the cached types if they are valid. if (iterationTypes !== noIterationTypes) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); @@ -82914,16 +83206,16 @@ var ts; } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : noIterationTypes); @@ -82989,7 +83281,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -83004,11 +83296,11 @@ var ts; function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } @@ -83088,13 +83380,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -83149,15 +83441,15 @@ var ts; if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" @@ -83263,7 +83555,7 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); @@ -83275,15 +83567,15 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync) || errorType : isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -83303,21 +83595,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -83328,7 +83620,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -83336,7 +83628,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -83357,7 +83649,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -83366,7 +83658,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -83403,7 +83695,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -83435,8 +83727,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -83448,7 +83740,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -83468,8 +83760,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -83498,9 +83790,9 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; var _loop_28 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared @@ -83520,7 +83812,7 @@ var ts; function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; var _loop_29 = function (info) { if (info === checkInfo) @@ -83561,7 +83853,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -83640,9 +83932,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -83729,7 +84021,7 @@ var ts; if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -83750,15 +84042,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -83790,18 +84082,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -83836,7 +84128,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -83886,7 +84178,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -83900,7 +84192,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -83919,12 +84211,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -83937,13 +84229,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -83954,9 +84246,9 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible @@ -83988,10 +84280,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -84007,7 +84299,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -84019,7 +84311,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -84027,11 +84319,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -84054,7 +84346,7 @@ var ts; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -84073,7 +84365,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -84087,7 +84379,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -84098,24 +84390,24 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { // either base or derived property is private - not override, skip it continue; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */ + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment continue; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -84123,12 +84415,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -84145,16 +84437,16 @@ var ts; continue; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { // method is overridden with method or property -- correct case continue; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -84220,20 +84512,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -84243,7 +84535,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -84258,7 +84550,7 @@ var ts; ts.setParent(reference, staticBlock); reference.flowNode = staticBlock.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) { + if (!(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */)) { return true; } } @@ -84273,7 +84565,7 @@ var ts; ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 32768 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -84286,7 +84578,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -84319,7 +84611,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -84331,8 +84623,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -84357,7 +84649,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -84374,7 +84666,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -84382,20 +84674,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -84405,60 +84697,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -84494,9 +84786,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -84530,7 +84822,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -84559,9 +84851,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -84592,7 +84884,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -84605,7 +84897,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -84615,7 +84907,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -84631,10 +84923,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -84644,7 +84936,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -84676,23 +84968,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -84703,12 +84995,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -84718,7 +85010,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -84729,20 +85021,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -84756,9 +85048,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -84799,39 +85091,39 @@ var ts; // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -84856,15 +85148,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -84890,11 +85182,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -84903,8 +85195,11 @@ var ts; var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration); var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!ts.isNightly()) { + grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -84937,11 +85232,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -84963,20 +85258,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -84985,7 +85280,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -85000,8 +85295,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -85009,10 +85304,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -85032,12 +85327,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -85047,7 +85342,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -85057,7 +85352,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -85105,15 +85400,15 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -85123,7 +85418,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -85135,8 +85430,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -85153,14 +85448,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -85176,10 +85471,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -85214,11 +85509,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -85264,177 +85559,177 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -85515,7 +85810,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -85527,38 +85822,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 163 /* SyntaxKind.TypeParameter */: + checkTypeParameterDeferred(node); + break; + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -85566,7 +85864,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -85578,9 +85876,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -85592,7 +85890,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -85612,13 +85910,13 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -85642,7 +85940,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -85712,14 +86010,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -85727,17 +86025,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -85745,17 +86043,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -85799,7 +86097,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -85807,25 +86105,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -85833,16 +86131,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -85870,13 +86168,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -85887,12 +86185,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -85902,7 +86200,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -85912,7 +86210,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -85922,17 +86220,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -85948,28 +86246,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -85980,13 +86278,13 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name)); if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { @@ -85998,16 +86296,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -86019,12 +86317,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -86039,7 +86337,7 @@ var ts; function resolveJSDocMemberName(name, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -86051,18 +86349,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -86076,12 +86374,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -86089,27 +86387,32 @@ var ts; return propertyDeclaration; } } - else if (ts.isMetaProperty(parent)) { - var parentType = getTypeOfNode(parent); - var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === 103 /* NewKeyword */) { + else if (ts.isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { + // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } + // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but + // we have a fake expression type made for other reasons already, whose transient `meta` + // member should more exactly be the kind of (declarationless) symbol we want. + // (See #44364 and #45031 for relevant implementation PRs) + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { + return getGlobalImportMetaExpressionType().members.get("meta"); + } + // no other meta properties are valid syntax, thus no others should have symbols + return undefined; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -86121,25 +86424,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -86148,7 +86451,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -86156,19 +86459,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -86178,14 +86481,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -86194,17 +86497,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -86235,7 +86538,7 @@ var ts; if (ts.isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { var symbol = getSymbolAtLocation(node); @@ -86245,7 +86548,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -86266,23 +86569,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -86292,7 +86595,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -86325,14 +86628,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -86342,8 +86645,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -86362,18 +86665,18 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] - : ts.singleElementArray(tryGetAliasTarget(symbol)); + : ts.singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol) { + function tryGetTarget(symbol) { var target; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -86412,13 +86715,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -86436,19 +86739,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -86471,7 +86774,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -86480,20 +86783,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -86509,9 +86812,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -86552,20 +86855,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -86573,7 +86876,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -86590,7 +86893,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -86603,9 +86906,9 @@ var ts; if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } - var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -86643,18 +86946,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); - } - function isOptionalUninitializedParameter(parameter) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86662,10 +86960,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86688,19 +86986,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -86710,7 +87008,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -86726,14 +87024,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -86752,28 +87050,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -86789,37 +87087,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -86838,7 +87136,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -86859,7 +87157,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -86967,18 +87265,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -86994,7 +87292,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -87031,7 +87329,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -87042,9 +87340,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -87091,7 +87389,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -87119,12 +87417,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -87195,7 +87493,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -87257,28 +87555,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -87292,29 +87590,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -87333,14 +87631,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -87354,69 +87652,69 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -87428,186 +87726,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ && - node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -87625,41 +87922,41 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.fail(); } @@ -87670,10 +87967,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -87702,7 +87999,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -87727,7 +88024,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -87762,7 +88059,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -87798,7 +88095,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -87827,7 +88124,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -87844,6 +88141,9 @@ var ts; return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { + if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } function checkGrammarClassDeclarationHeritageClauses(node) { @@ -87852,7 +88152,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -87865,7 +88165,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -87881,14 +88181,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -87899,21 +88199,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -87931,7 +88231,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -87942,23 +88242,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */) { + if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -87973,25 +88273,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -88006,14 +88306,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -88033,7 +88333,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -88043,7 +88343,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -88078,16 +88378,32 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -88096,8 +88412,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -88108,12 +88424,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -88128,20 +88444,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -88151,22 +88467,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -88174,11 +88490,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -88200,17 +88516,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -88220,26 +88536,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -88247,9 +88563,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -88262,10 +88578,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -88283,7 +88599,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -88291,17 +88607,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -88312,11 +88628,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -88324,8 +88640,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -88340,13 +88656,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -88370,18 +88686,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -88389,7 +88705,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -88406,8 +88722,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -88419,7 +88735,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88428,7 +88744,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -88441,7 +88757,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -88458,8 +88774,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -88486,15 +88802,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -88512,12 +88828,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -88575,7 +88891,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -88585,11 +88901,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -88605,11 +88921,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88631,14 +88947,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -88646,7 +88962,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -88655,10 +88971,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -88669,7 +88985,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -88686,19 +89002,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -88711,7 +89027,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -88732,7 +89048,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -88766,7 +89082,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -88774,7 +89090,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -88782,10 +89098,10 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } var nodeArguments = node.arguments; if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) { @@ -88793,7 +89109,7 @@ var ts; checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { var assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } if (nodeArguments.length === 0 || nodeArguments.length > 2) { @@ -88809,14 +89125,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -88825,35 +89141,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -88865,9 +89181,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -88875,7 +89191,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -88897,14 +89213,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -88924,17 +89240,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -89048,7 +89364,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -89056,11 +89372,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -89107,8 +89423,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -89154,446 +89470,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -89818,7 +90134,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -89828,7 +90144,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -89971,14 +90287,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -90055,8 +90371,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -90106,19 +90422,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -90186,7 +90502,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -90279,12 +90595,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -90335,7 +90651,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -90348,13 +90664,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -90385,23 +90701,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90419,9 +90735,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90502,7 +90818,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -90517,27 +90833,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -90599,7 +90915,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -90884,9 +91200,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -90927,14 +91243,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -90949,10 +91265,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -91155,7 +91471,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -91211,8 +91527,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -91238,14 +91554,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -91296,17 +91612,17 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -91317,7 +91633,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -91340,7 +91656,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -91360,10 +91676,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -91376,7 +91692,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -91384,13 +91700,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -91410,15 +91726,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -91438,30 +91754,30 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -91472,80 +91788,80 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. // falls through - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.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 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91555,7 +91871,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91565,35 +91881,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -91603,40 +91919,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -91650,28 +91966,28 @@ var ts; return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -91680,16 +91996,16 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return ts.visitEachChild(node, visitor, context); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); - var classStatement = facts & 2 /* HasConstructorDecorators */ + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var classStatement = facts & 2 /* ClassFacts.HasConstructorDecorators */ ? createClassDeclarationHeadWithDecorators(node, name) : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; @@ -91697,7 +92013,7 @@ var ts; addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -91709,20 +92025,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -91738,21 +92054,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -91768,7 +92084,7 @@ var ts; // ${members} // } // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : undefined; var classDeclaration = factory.createClassDeclaration( @@ -91777,8 +92093,8 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); @@ -91879,7 +92195,7 @@ var ts; var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -91897,7 +92213,7 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); @@ -92030,12 +92346,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92186,9 +92502,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -92198,7 +92514,7 @@ var ts; : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); ts.setTextRange(helper, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); return helper; } /** @@ -92226,12 +92542,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); return expression; } @@ -92257,7 +92573,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -92294,13 +92610,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); @@ -92316,10 +92632,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -92329,7 +92645,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -92340,12 +92656,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -92362,15 +92678,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -92407,7 +92723,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -92452,83 +92768,83 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return factory.createVoidZero(); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return serializeTypeNode(node.type); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return factory.createIdentifier("Array"); - case 177 /* TypePredicate */: - case 133 /* BooleanKeyword */: + case 177 /* SyntaxKind.TypePredicate */: + case 133 /* SyntaxKind.BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: switch (node.literal.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: - case 8 /* NumericLiteral */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 8 /* SyntaxKind.NumericLiteral */: return factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 151 /* SymbolKeyword */: - return languageVersion < 2 /* ES2015 */ + case 151 /* SyntaxKind.SymbolKeyword */: + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return serializeTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -92541,13 +92857,13 @@ var ts; var serializedUnion; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -92607,7 +92923,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES2015 */ + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -92629,12 +92945,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -92650,14 +92966,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -92685,7 +93001,7 @@ var ts; * available. */ function getGlobalBigIntNameWithFallback() { - return languageVersion < 99 /* ESNext */ + return languageVersion < 99 /* ScriptTarget.ESNext */ ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), /*questionToken*/ undefined, factory.createIdentifier("BigInt"), /*colonToken*/ undefined, factory.createIdentifier("Object")) @@ -92748,7 +93064,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -92776,7 +93092,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { return undefined; } var updated = factory.updatePropertyDeclaration(node, @@ -92807,11 +93123,11 @@ var ts; } var statements = []; resumeLexicalEnvironment(); - var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); + var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); } // Transform parameters into property assignments. Transforms this: // @@ -92830,12 +93146,12 @@ var ts; if (superStatementIndex >= 0) { ts.addRange(statements, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor + // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = ts.addRange(parameterPropertyAssignments, statements); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - // Add remaining statements from the body, skipping the super() call if it was found - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1)); + // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -92855,10 +93171,10 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node) { @@ -92885,7 +93201,7 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { @@ -92961,7 +93277,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -92981,7 +93297,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -92999,7 +93315,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93076,7 +93392,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93084,7 +93400,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93092,7 +93408,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93158,7 +93474,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93246,12 +93562,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93276,7 +93592,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93286,7 +93602,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93307,7 +93623,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93315,7 +93631,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93323,7 +93639,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93376,7 +93692,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93423,13 +93739,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93452,8 +93768,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*decorators*/ undefined, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) @@ -93477,14 +93793,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93525,8 +93841,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93586,7 +93902,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -93599,7 +93915,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -93620,7 +93936,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -93628,7 +93944,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -93637,7 +93953,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -93646,7 +93962,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Creates a statement for the provided expression. This is used in calls to `map`. @@ -93691,7 +94007,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -93708,37 +94024,37 @@ var ts; : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* TypeScriptSubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -93753,11 +94069,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -93771,7 +94087,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -93780,7 +94096,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -93797,11 +94113,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -93812,8 +94128,8 @@ var ts; || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -93839,9 +94155,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -93867,7 +94183,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -93930,13 +94246,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -93962,7 +94278,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -93970,50 +94286,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 8388608 /* ContainsClassFields */) { + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 8388608 /* ContainsClassFields */ || - node.transformFlags & 33554432 /* ContainsLexicalSuper */ && + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94032,17 +94348,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94072,7 +94388,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94088,19 +94404,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94149,10 +94465,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94214,11 +94530,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94237,7 +94553,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94256,7 +94572,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94270,7 +94586,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var info = void 0; if (info = accessPrivateIdentifier(node.operand.name)) { @@ -94279,7 +94595,7 @@ var ts; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94302,7 +94618,7 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { var operand = visitInvalidSuperProperty(node.operand); return ts.isPrefixUnaryExpression(node) ? factory.updatePrefixUnaryExpression(node, operand) : @@ -94418,7 +94734,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94445,7 +94761,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94487,7 +94803,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94502,12 +94818,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94547,28 +94863,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94576,8 +94892,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94590,19 +94906,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -94631,7 +94947,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94641,19 +94957,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -94682,12 +94998,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -94742,13 +95058,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -94781,7 +95097,7 @@ var ts; } resumeLexicalEnvironment(); var needsSyntheticConstructor = !constructor && isDerivedClass; - var indexOfFirstStatementAfterSuper = 0; + var indexOfFirstStatementAfterSuperAndPrologue = 0; var prologueStatementCount = 0; var superStatementIndex = -1; var statements = []; @@ -94790,8 +95106,11 @@ var ts; superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; } } if (needsSyntheticConstructor) { @@ -94827,22 +95146,20 @@ var ts; } } if (parameterPropertyDeclarationCount > 0) { - var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); // If there was a super() call found, add parameter properties immediately after it if (superStatementIndex >= 0) { ts.addRange(statements, parameterProperties); } - // If a synthetic super() call was added, add them just after it - else if (needsSyntheticConstructor) { - statements = __spreadArray(__spreadArray([ - statements[0] - ], parameterProperties, true), statements.slice(1), true); - } - // Since there wasn't a super() call, add them to the top of the constructor else { - statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true); + // Add add parameter properties to the top of the constructor after the prologue + var superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) + superAndPrologueStatementCount++; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true); } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -94852,7 +95169,7 @@ var ts; addPropertyOrClassStaticBlockStatements(statements, properties, receiver); // Add existing statements after the initial prologues and super call if (constructor) { - ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), @@ -94937,7 +95254,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -94956,7 +95273,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -94976,7 +95293,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -94995,32 +95312,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95059,13 +95376,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95075,10 +95392,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95088,7 +95405,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95109,24 +95426,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95139,8 +95456,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95173,7 +95490,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95193,7 +95510,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95226,7 +95543,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95236,7 +95553,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95245,12 +95562,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95261,12 +95578,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95282,7 +95599,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95294,7 +95611,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95305,12 +95622,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95321,12 +95638,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95343,9 +95660,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95387,9 +95704,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95403,7 +95720,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95443,7 +95760,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95562,8 +95879,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -95575,10 +95892,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -95594,39 +95911,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -95634,27 +95951,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -95737,7 +96054,7 @@ var ts; /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95753,7 +96070,7 @@ var ts; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95768,7 +96085,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95783,7 +96100,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95804,7 +96121,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -95858,9 +96175,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -95886,7 +96203,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -95899,10 +96216,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -95946,21 +96263,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -95973,8 +96290,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96001,30 +96318,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96044,19 +96361,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -96066,7 +96383,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -96076,7 +96393,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -96091,20 +96408,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -96174,7 +96491,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -96206,7 +96523,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -96228,88 +96545,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -96323,15 +96640,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -96343,7 +96660,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -96352,7 +96669,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -96363,7 +96680,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -96386,7 +96703,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -96413,9 +96730,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -96436,10 +96753,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -96467,10 +96784,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -96482,7 +96799,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -96508,8 +96825,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -96526,8 +96843,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -96555,7 +96872,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -96575,10 +96892,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -96597,18 +96914,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -96616,15 +96933,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -96640,7 +96957,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -96658,7 +96975,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -96704,13 +97021,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateMethodDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96723,13 +97040,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateFunctionDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96753,13 +97070,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96776,13 +97093,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -96793,10 +97110,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -96835,11 +97152,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96848,7 +97165,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96864,32 +97181,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96897,21 +97214,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -96924,8 +97241,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96952,30 +97269,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96995,14 +97312,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -97027,11 +97344,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -97059,29 +97376,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97123,7 +97440,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -97146,10 +97463,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -97158,7 +97475,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -97168,8 +97485,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -97179,17 +97496,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -97206,7 +97523,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -97240,11 +97557,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -97294,7 +97611,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -97318,12 +97635,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -97349,7 +97666,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -97371,7 +97688,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -97388,7 +97705,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -97404,7 +97721,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -97413,13 +97730,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97427,15 +97744,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -97504,7 +97821,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -97569,7 +97886,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -97609,14 +97926,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - else if (node.kind === 10 /* StringLiteral */) { + else if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 288 /* JsxExpression */) { + else if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -97710,7 +98027,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -98013,11 +98330,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98025,9 +98342,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98217,7 +98534,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -98227,7 +98544,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -98238,15 +98555,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -98261,11 +98578,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -98277,9 +98594,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -98287,115 +98604,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -98406,14 +98723,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -98421,17 +98738,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -98447,11 +98764,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -98478,30 +98795,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -98510,15 +98827,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -98551,18 +98868,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -98619,25 +98936,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -98655,19 +98972,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98693,7 +99010,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -98704,10 +99021,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -98741,7 +99058,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98756,7 +99073,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -98800,7 +99117,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -98810,7 +99127,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -98833,7 +99150,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -98872,7 +99189,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -98893,7 +99210,7 @@ var ts; // ``` insertCaptureThisForNodeIfNeeded(prologue, constructor); } - var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), + var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), /*location*/ constructor.body.statements), /*multiLine*/ true); ts.setTextRange(body, constructor.body); @@ -98922,11 +99239,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -98934,7 +99251,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -98943,10 +99260,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -99035,11 +99352,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -99057,11 +99374,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -99092,10 +99409,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -99105,7 +99422,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -99117,13 +99434,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -99136,7 +99453,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -99150,7 +99467,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -99158,38 +99475,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -99197,11 +99514,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -99220,21 +99537,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -99273,7 +99590,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -99281,7 +99598,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -99295,7 +99612,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -99311,20 +99628,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -99332,7 +99649,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -99355,12 +99672,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -99369,9 +99686,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -99381,17 +99698,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -99406,13 +99723,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, @@ -99430,14 +99747,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -99480,7 +99797,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -99499,7 +99816,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -99520,10 +99837,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -99533,11 +99850,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99568,9 +99885,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -99598,12 +99915,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -99612,10 +99929,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -99632,7 +99949,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99641,11 +99958,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -99654,7 +99971,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 262144 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -99720,18 +100037,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -99758,16 +100075,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -99787,50 +100104,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -99878,7 +100195,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -99910,18 +100227,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -99937,33 +100254,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -99978,9 +100295,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 524288 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 524288 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -99993,7 +100310,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -100005,7 +100322,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -100021,7 +100338,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -100032,7 +100349,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -100052,7 +100369,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -100096,11 +100413,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -100125,11 +100442,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -100138,7 +100455,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -100251,15 +100568,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -100285,12 +100602,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -100352,7 +100669,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -100361,17 +100678,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -100391,18 +100708,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -100415,7 +100732,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -100424,27 +100741,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -100452,7 +100769,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -100511,19 +100828,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -100545,20 +100862,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -100613,14 +100930,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -100629,7 +100946,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -100648,7 +100965,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -100661,17 +100978,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -100714,11 +101031,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -100791,7 +101108,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -100848,15 +101165,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -100870,7 +101187,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -100882,12 +101199,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -100976,13 +101293,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -100998,12 +101315,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -101011,7 +101328,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -101041,7 +101358,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -101076,15 +101393,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -101096,13 +101413,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -101112,9 +101429,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -101122,16 +101439,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -101142,7 +101459,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -101156,7 +101473,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -101172,10 +101489,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -101188,9 +101505,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -101201,7 +101518,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -101238,9 +101555,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -101257,19 +101574,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -101292,18 +101609,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -101322,9 +101639,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -101384,7 +101701,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -101564,11 +101881,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -101622,7 +101939,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -101645,7 +101962,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -101659,13 +101976,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -101678,30 +101995,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -101716,23 +102033,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -101745,9 +102062,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -101906,13 +102223,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101937,9 +102254,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -101955,7 +102272,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -101967,7 +102284,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -101999,7 +102316,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -102033,13 +102350,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -102056,12 +102373,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -102106,7 +102423,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -102172,7 +102489,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -102361,35 +102678,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -102819,7 +103136,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -102832,7 +103149,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -102964,7 +103281,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -102977,7 +103294,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -103008,7 +103325,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -103054,7 +103371,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -103068,7 +103385,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -103097,7 +103414,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -103107,7 +103424,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -103119,8 +103436,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -103133,7 +103450,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -103146,18 +103463,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -103167,24 +103484,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -103192,7 +103509,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -103202,7 +103519,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -103219,7 +103536,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -103231,7 +103548,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103245,7 +103562,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -103258,7 +103575,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -103268,7 +103585,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103277,7 +103594,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -103286,14 +103603,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -103305,8 +103622,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -103314,7 +103631,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -103322,7 +103639,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -103419,7 +103736,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -103431,7 +103748,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -103443,8 +103760,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -103457,7 +103774,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -103466,7 +103783,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -103480,7 +103797,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -103489,7 +103806,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -103500,7 +103817,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -103511,7 +103828,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -103520,7 +103837,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -103529,7 +103846,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -103538,7 +103855,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -103547,13 +103864,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -103597,7 +103914,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -103770,8 +104087,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -103781,18 +104098,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -103816,33 +104133,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -103892,8 +104209,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -103904,9 +104221,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -103917,9 +104234,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -103930,9 +104247,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -103943,8 +104260,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -103955,9 +104272,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -103965,7 +104282,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -103992,12 +104309,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -104013,7 +104330,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 4194304 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -104149,7 +104466,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -104234,7 +104551,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -104303,13 +104620,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -104325,23 +104642,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -104350,30 +104667,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4194304 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -104389,24 +104706,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -104432,7 +104749,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -104458,7 +104775,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -104501,7 +104818,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -104528,7 +104845,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -104564,7 +104881,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -104582,7 +104899,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -104603,7 +104920,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -104623,13 +104940,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -104638,7 +104955,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -104685,7 +105002,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -104699,7 +105016,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -104733,7 +105050,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -104743,11 +105060,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -104788,12 +105105,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -104844,7 +105161,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), @@ -104872,7 +105189,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); @@ -104899,7 +105216,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -104957,7 +105274,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -104972,7 +105289,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -104994,7 +105311,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -105006,7 +105323,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -105049,10 +105366,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -105135,8 +105452,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -105181,7 +105498,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -105194,7 +105511,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -105209,7 +105526,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -105221,7 +105538,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -105248,8 +105565,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -105265,7 +105582,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -105290,7 +105607,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -105325,13 +105642,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -105340,9 +105657,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105351,9 +105668,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105366,16 +105683,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -105464,11 +105781,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -105488,7 +105805,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -105535,7 +105852,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -105657,8 +105974,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 1048576 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -105692,7 +106009,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -105758,7 +106075,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -105782,19 +106099,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -105853,13 +106170,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -105935,7 +106252,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -105988,7 +106305,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -106038,9 +106355,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -106051,7 +106368,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -106103,9 +106420,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -106116,7 +106433,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106165,10 +106482,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -106262,8 +106579,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -106323,7 +106640,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106335,7 +106652,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -106348,43 +106665,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -106566,30 +106883,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 4194304 /* TransformFlags.ContainsDynamicImport */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -106639,7 +106956,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -106669,7 +106986,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -106685,7 +107002,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -106730,8 +107047,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106747,7 +107064,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -106782,10 +107099,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -106797,7 +107114,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -106832,11 +107149,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -106848,7 +107165,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -106926,7 +107243,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -106969,8 +107286,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -107009,14 +107326,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -107034,7 +107351,7 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause( @@ -107042,16 +107359,16 @@ var ts; /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -107072,12 +107389,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); @@ -107145,7 +107462,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -107154,7 +107471,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -107177,8 +107494,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -107225,7 +107542,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -107280,14 +107597,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107309,14 +107626,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -107340,7 +107657,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -107358,31 +107675,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107405,7 +107722,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -107422,14 +107739,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -107444,36 +107761,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -107485,9 +107802,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -107510,40 +107827,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -107554,61 +107871,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -107625,7 +107942,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -107674,7 +107991,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -107693,13 +108010,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -107758,7 +108075,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -107767,7 +108084,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -107803,7 +108120,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -107874,10 +108191,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -107900,14 +108217,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -108044,11 +108361,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -108056,7 +108373,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -108069,7 +108386,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = factory.updateParameterDeclaration(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -108086,7 +108403,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -108094,19 +108411,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -108114,12 +108431,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -108130,28 +108447,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -108178,7 +108495,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -108215,7 +108532,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -108241,7 +108558,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -108261,7 +108578,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -108279,34 +108596,44 @@ var ts; if (!decl.importClause) { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // The `importClause` visibility corresponds to the default's visibility. var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, - /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } // Named imports (optionally with visible default) var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Augmentation of export depends on import if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, - /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Nothing visible } + function getResolutionModeOverrideForClauseInNightly(assertClause) { + var mode = ts.getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!ts.isNightly()) { + context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } function transformAndReplaceLatePaintedStatements(statements) { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. @@ -108325,7 +108652,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -108383,10 +108710,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -108404,29 +108731,29 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -108436,48 +108763,48 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateSetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { + case 176 /* SyntaxKind.IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -108485,13 +108812,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -108503,22 +108830,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -108541,7 +108868,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -108551,7 +108878,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -108561,17 +108888,17 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -108579,7 +108906,9 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); + preserveJsDoc(statement, input); + ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -108590,22 +108919,26 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { + if (lateMarkedStatements) { + while (ts.orderedRemoveItem(lateMarkedStatements, input)) + ; + } if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -108626,14 +108959,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -108642,7 +108975,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -108661,10 +108994,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -108675,11 +109008,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, @@ -108700,17 +109033,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -108746,7 +109079,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -108756,10 +109089,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -108801,26 +109134,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -108831,10 +109164,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -108845,7 +109178,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -108853,7 +109186,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -108876,7 +109209,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -108924,12 +109257,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 125951 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 125951 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -108949,13 +109282,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -108965,22 +109298,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 125951 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 125951 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -108989,52 +109322,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -109052,7 +109385,7 @@ var ts; return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return ts.transformNodeModule; default: @@ -109091,35 +109424,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -109173,11 +109506,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -109190,7 +109523,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -109220,13 +109553,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -109250,17 +109583,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -109278,15 +109611,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -109296,23 +109629,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -109322,7 +109655,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -109338,26 +109671,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -109369,9 +109702,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -109384,8 +109717,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -109399,19 +109732,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -109420,8 +109753,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -109433,7 +109766,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -109476,8 +109809,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -109486,12 +109819,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -109505,8 +109838,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -109517,14 +109850,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -109539,7 +109872,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -109578,7 +109911,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -109644,7 +109977,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -109652,7 +109985,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -109661,7 +109994,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -109669,7 +110002,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -109683,11 +110016,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -109703,9 +110036,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -109730,20 +110063,20 @@ var ts; addOutput(buildInfoPath); } function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) { - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -109775,7 +110108,7 @@ var ts; /*@internal*/ function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; /*@internal*/ @@ -109812,17 +110145,17 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) continue; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -109831,7 +110164,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -109869,13 +110202,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -110010,7 +110343,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SyntaxKind.SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -110021,7 +110354,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -110033,8 +110366,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -110046,6 +110379,7 @@ var ts; else { printer.writeFile(sourceFile, writer, sourceMapGenerator); } + var sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -110057,7 +110391,8 @@ var ts; if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + sourceMapUrlPos = writer.getTextPos(); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { @@ -110069,13 +110404,13 @@ var ts; writer.writeLine(); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -110106,7 +110441,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -110199,8 +110534,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -110286,7 +110621,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -110338,7 +110673,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -110378,20 +110713,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -110447,11 +110782,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -110486,7 +110821,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -110497,7 +110832,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -110507,7 +110842,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -110534,7 +110869,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -110544,7 +110879,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -110583,7 +110918,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -110591,30 +110926,30 @@ var ts; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); + return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile))); } function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -110623,7 +110958,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -110639,12 +110974,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -110652,17 +110987,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -110672,7 +111007,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -110698,346 +111033,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -111049,101 +111384,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -111151,7 +111486,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -111161,7 +111496,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -111191,7 +111526,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -111233,7 +111568,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -111261,7 +111596,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -111291,9 +111626,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -111312,25 +111647,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -111338,7 +111673,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -111353,7 +111688,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -111390,7 +111725,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -111458,7 +111793,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -111568,8 +111903,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -111582,16 +111917,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -111600,10 +111935,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -111636,7 +111971,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -111650,7 +111985,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -111659,13 +111994,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -111675,7 +112010,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -111683,14 +112018,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -111698,7 +112033,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -111717,7 +112052,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -111733,12 +112068,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -111756,29 +112091,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -111804,7 +112139,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -111817,12 +112152,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111835,17 +112170,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111867,12 +112202,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -111891,22 +112226,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -111931,9 +112266,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -111974,12 +112309,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -112010,11 +112345,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -112025,7 +112360,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -112047,15 +112382,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -112098,10 +112433,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -112122,21 +112457,21 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) - if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -112146,14 +112481,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -112169,45 +112504,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -112216,12 +112551,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -112244,13 +112579,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -112290,40 +112625,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -112332,13 +112667,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -112354,7 +112689,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -112372,7 +112707,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -112409,23 +112744,23 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { return false; } - if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { + if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) { + if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -112440,14 +112775,9 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -112460,11 +112790,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -112479,15 +112809,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -112500,10 +112830,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -112526,13 +112856,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -112554,27 +112884,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112583,12 +112913,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -112599,20 +112929,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112623,37 +112953,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -112663,10 +112993,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -112674,26 +113004,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112705,7 +113035,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -112716,7 +113046,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -112735,7 +113065,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -112748,7 +113078,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -112777,7 +113107,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -112808,17 +113138,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112829,30 +113159,31 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { var emitAsSingleStatement = statements.length === 1 && ( // treat synthesized nodes as located on the same line for emit purposes - ts.nodeIsSynthesized(parentNode) || + !currentSourceFile || + ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -112860,15 +113191,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -112888,7 +113219,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -112905,7 +113236,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -112936,12 +113267,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -112975,13 +113306,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -113000,7 +113331,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -113018,14 +113349,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -113073,16 +113404,14 @@ var ts; function emitSourceFile(node) { writeLine(); var statements = node.statements; - if (emitBodyWithDetachedComments) { - // Emit detached comment if there are no prologue directives or if the first node is synthesized. - // The synthesized node will have no leading comment so some comments may be missed. - var shouldEmitDetachedComment = statements.length === 0 || - !ts.isPrologueDirective(statements[0]) || - ts.nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -113108,21 +113437,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -113130,28 +113459,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { var directive = types_24[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -113162,22 +113491,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -113198,7 +113527,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -113219,7 +113548,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -113312,7 +113641,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 262656 /* Modifiers */); + emitList(node, modifiers, 262656 /* ListFormat.Modifiers */); writeSpace(); } } @@ -113326,7 +113655,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -113356,7 +113685,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -113364,7 +113693,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -113373,19 +113702,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -113406,32 +113735,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -113447,11 +113776,11 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -113460,7 +113789,7 @@ var ts; } return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -113471,28 +113800,28 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } else { ts.Debug.type(children); // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -113503,7 +113832,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -113515,7 +113844,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -113525,14 +113854,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -113555,11 +113884,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (hasTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -113571,11 +113900,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -113584,14 +113913,14 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -113676,7 +114005,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -113726,13 +114055,13 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -113752,11 +114081,11 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild_1.kind === 11 /* JsxText */) { + if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { @@ -113769,18 +114098,18 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); } @@ -113794,7 +114123,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -113803,18 +114132,18 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -113825,7 +114154,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -113854,14 +114183,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -113870,14 +114199,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -113887,7 +114216,7 @@ var ts; if (ts.getStartsOnNewLine(node2)) { return 1; } - if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); } @@ -113897,10 +114226,10 @@ var ts; } function isEmptyBlock(block) { return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -113909,41 +114238,48 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return generateName(node); } - else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { - return ts.idText(node); - } - else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (ts.isStringLiteral(node) && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + var sourceFile = currentSourceFile; // const needed for control flow + var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node); + if (ts.isMemberName(node)) { + if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) { + return ts.idText(node); + } } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + else { + ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary + if (!canUseSourceFile) { + return node.text; + } + } + return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -113954,7 +114290,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -113970,84 +114306,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -114056,12 +114392,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -114080,7 +114416,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -114119,7 +114455,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -114133,7 +114469,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -114143,12 +114479,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -114180,7 +114516,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -114234,48 +114570,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -114291,7 +114627,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -114302,7 +114638,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -114315,7 +114651,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -114323,7 +114659,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -114337,25 +114673,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -114365,7 +114701,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -114374,18 +114710,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -114403,25 +114739,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -114497,7 +114833,7 @@ var ts; return true; } function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); @@ -114510,7 +114846,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -114524,7 +114860,7 @@ var ts; forEachTrailingCommentToEmit(pos, emitTrailingComment); } function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { @@ -114546,15 +114882,19 @@ var ts; exitComment(); } function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); @@ -114587,6 +114927,8 @@ var ts; return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { + if (!currentSourceFile) + return; // get the leading comments from detachedPos var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { @@ -114598,7 +114940,7 @@ var ts; ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -114609,7 +114951,7 @@ var ts; } } function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); @@ -114621,7 +114963,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps function getParsedSourceMap(node) { @@ -114631,7 +114973,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -114649,12 +114991,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -114664,11 +115006,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -114721,17 +115063,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -114762,23 +115104,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -115144,7 +115486,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -115153,11 +115495,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -115167,7 +115509,7 @@ var ts; if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored - if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileOrDirectoryPath)) { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; @@ -115179,9 +115521,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -115214,7 +115556,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -115249,36 +115591,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -115288,16 +115630,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -115509,7 +115851,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -115520,7 +115862,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -115536,7 +115878,11 @@ var ts; return newValue; }; if (originalWriteFile) { - host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) { + host.writeFile = function (fileName, data) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); @@ -115550,7 +115896,7 @@ var ts; sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } // directoryExists @@ -115604,12 +115950,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -115697,9 +116043,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -115713,7 +116059,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -115776,7 +116122,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115882,7 +116228,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -116062,11 +116408,11 @@ var ts; */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { - case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; @@ -116116,7 +116462,6 @@ var ts; ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -116222,7 +116567,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -116303,16 +116648,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -116340,7 +116685,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -116349,19 +116694,19 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId }); } ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -116483,14 +116828,15 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, + writeFile: writeFile, }; onProgramCreateComplete(); // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -116502,17 +116848,52 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; + function addResolutionDiagnostics(list) { + if (!list) + return; + for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { + var elem = list_3[_i]; + programDiagnostics.add(elem); + } + } + function pullDiagnosticsFromCache(names, containingFile) { + var _a; + if (!moduleResolutionCache) + return; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + var containingDir = ts.getDirectoryPath(containingFileName); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var n = names_4[_i]; + // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less + var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + var name = typeof n === "string" ? n : n.fileName; + i++; + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + if (ts.isExternalModuleNameRelative(name)) + continue; + var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -116521,7 +116902,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -116531,7 +116912,7 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) + if (redirect || !ts.isDeclarationFileName(file.originalFileName)) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case @@ -116603,7 +116984,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -116758,22 +117139,22 @@ var ts; function tryReuseStructureFromOldProgram() { var _a; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -116781,12 +117162,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -116801,7 +117182,7 @@ var ts; ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; @@ -116810,7 +117191,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -116818,7 +117199,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -116835,9 +117216,9 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } @@ -116845,49 +117226,49 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); @@ -116908,7 +117289,7 @@ var ts; // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -116919,18 +117300,18 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping @@ -116961,7 +117342,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -116980,7 +117361,7 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, getSymlinkCache: getSymlinkCache, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + writeFile: writeFileCallback || writeFile, isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { @@ -117000,9 +117381,12 @@ var ts; getFileIncludeReasons: program.getFileIncludeReasons, }; } + function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -117054,7 +117438,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -117174,7 +117558,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -117182,8 +117566,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -117262,22 +117646,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -117285,65 +117669,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -117352,53 +117736,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 124 /* StaticKeyword */) { + if (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -117411,27 +117795,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -117501,20 +117885,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -117545,7 +117929,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -117567,7 +117951,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -117622,7 +118006,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -117737,7 +118121,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -117922,7 +118306,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -117932,7 +118316,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -117965,13 +118349,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -118010,14 +118394,14 @@ var ts; var fileName = ts.toFileNameLowerCase(ref.fileName); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); var mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { - programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { + programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, }); } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -118076,7 +118460,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -118096,7 +118480,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -118143,7 +118527,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -118204,7 +118588,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -118344,19 +118728,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -118373,7 +118757,7 @@ var ts; } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && - ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -118395,7 +118779,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -118417,7 +118801,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -118431,7 +118815,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -118439,12 +118823,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -118523,7 +118907,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -118762,7 +119146,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -118772,16 +119156,16 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -118882,12 +119266,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -118940,7 +119324,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -119036,17 +119420,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -119065,7 +119449,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -119080,7 +119464,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -119105,13 +119489,9 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - var manyToManyPathMapCount = 0; function createManyToManyPathMap() { function create(forward, reverse, deleted) { - var version = 0; var map = { - id: manyToManyPathMapCount++, - version: function () { return version; }, clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, @@ -119127,30 +119507,29 @@ var ts; } set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); forward.delete(k); - version++; return true; }, set: function (k, vSet) { - var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + deleted === null || deleted === void 0 ? void 0 : deleted.delete(k); var existingVSet = forward.get(k); forward.set(k, vSet); existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(function (v) { if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } return map; }, + clear: function () { + forward.clear(); + reverse.clear(); + deleted === null || deleted === void 0 ? void 0 : deleted.clear(); + } }; return map; } @@ -119165,11 +119544,10 @@ var ts; } set.add(v); } - function deleteFromMultimap(map, k, v, removeEmpty) { - if (removeEmpty === void 0) { removeEmpty = true; } + function deleteFromMultimap(map, k, v) { var set = map.get(k); if (set === null || set === void 0 ? void 0 : set.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -119398,7 +119776,7 @@ var ts; /*forceDtsEmit*/ true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -119448,6 +119826,7 @@ var ts; } } } + BuilderState.updateExportedModules = updateExportedModules; /** * Updates the exported modules from cache into state's exported modules map * This should be called whenever it is safe to commit the state of the builder @@ -119456,20 +119835,6 @@ var ts; var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - var cacheId = exportedModulesMapCache.id; - var cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - // If this is the same cache at the same version as last time this BuilderState - // was updated, there's no need to update again - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } @@ -119718,7 +120083,7 @@ var ts; } else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -119803,7 +120168,8 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash) { + function getNextAffectedFile(state, cancellationToken, computeHash, host) { + var _a; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -119814,7 +120180,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -119826,6 +120192,7 @@ var ts; ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); state.currentAffectedFilesSignatures.clear(); ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); state.affectedFiles = undefined; } // Get next changed file @@ -119855,6 +120222,11 @@ var ts; state.seenAffectedFiles = new ts.Set(); } } + function clearAffectedFilesPendingEmit(state) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } /** * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet */ @@ -119874,49 +120246,48 @@ var ts; } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } + function removeDiagnosticsOfLibraryFiles(state) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var program_1 = ts.Debug.checkDefined(state.program); + var options_2 = program_1.getCompilerOptions(); + ts.forEach(program_1.getSourceFiles(), function (f) { + return program_1.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2, program_1) && + removeSemanticDiagnosticsOf(state, f.resolvedPath); + }); + } + } /** * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.checkDefined(state.program); - var options_2 = program_1.getCompilerOptions(); - ts.forEach(program_1.getSourceFiles(), function (f) { - return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2, program_1) && - removeSemanticDiagnosticsOf(state, f.resolvedPath); - }); - } + removeDiagnosticsOfLibraryFiles(state); // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } - else { - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); - } - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); - } + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) + return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -119927,11 +120298,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, - /* useFileVersionAsSignature */ true); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -119953,16 +120323,41 @@ var ts; var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } + function forEachKeyOfExportedModulesMap(state, filePath, fn) { + // Go through exported modules from cache first + var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); + var result = keys && ts.forEachKey(keys, fn); + if (result) + return result; + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + keys = state.exportedModulesMap.getKeys(filePath); + return keys && ts.forEachKey(keys, function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? + fn(exportedFromPath) : + undefined; + }); + } + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + var _a; + if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) + return false; + // Every file needs to be handled + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + removeDiagnosticsOfLibraryFiles(state); + return true; + } /** - * Iterate on referencing modules that export entities from affected file + * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - var _a, _b; + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; - } if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself @@ -119975,7 +120370,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -119987,56 +120384,38 @@ var ts; var seenFileAndExportsOfFile = new ts.Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + return true; + var references = state.referencedMap.getKeys(exportedFromPath); + return references && ts.forEachKey(references, function (filePath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + }); }); } /** - * Iterate on files referencing referencedPath + * handle dts and semantic diagnostics on file and iterate on anything that exports this file + * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { var _a; - (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { - return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); - }); - } - /** - * fn on file and iterate on anything that exports this file - */ - function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { - var _a, _b, _c; - if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - fn(state, filePath); + if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) + return undefined; + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) - (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file - fn(state, referencingFilePath); - } // Dont add to seen since this is not yet done with the export removal - ); + handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal + state, referencingFilePath, cancellationToken, computeHash, host); + }); + return undefined; } /** * This is called after completing operation on the next affected file. @@ -120125,13 +120504,18 @@ var ts; var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + // If file version is same as signature, dont serialize signature + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // If file info only contains version and signature and both are same we can just write string value.version : - actualSignature !== undefined ? + actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo signature === undefined ? + // If we havent computed signature, use fileInfo as is value : + // Serialize fileInfo with new updated signature { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // Signature of the FileInfo is undefined, serialize it as false { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; @@ -120376,8 +120760,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -120390,7 +120774,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -120407,7 +120791,43 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + } + function getWriteFileUpdatingSignatureCallback(writeFile) { + return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + var _a; + if (ts.isDeclarationFileName(fileName)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; + if (signature === file.version) { + var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { // Update it + if (host.storeFilesChangingSignatureDuringEmit) + (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); + if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { + state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) + ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) + writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else + state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; } /** * Emits the JavaScript and declaration files. @@ -120421,56 +120841,52 @@ var ts; * in that order would be used to write the files */ function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var restorePendingEmitOnHandlingNoEmitSuccess = false; - var savedAffectedFilesPendingEmit; - var savedAffectedFilesPendingEmitKind; - var savedAffectedFilesPendingEmitIndex; - // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors - // This ensures pending files to emit is updated in tsbuildinfo - // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit) - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !ts.outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } + var _a; if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } // Emit only affected files if using builder for emit - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - // Emit and report any errors we ran into. - var sourceMaps = []; - var emitSkipped = false; - var diagnostics = void 0; - var emittedFiles = []; - var affectedEmitResult = void 0; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + // Emit and report any errors we ran into. + var sourceMaps = []; + var emitSkipped = false; + var diagnostics = void 0; + var emittedFiles = []; + var affectedEmitResult = void 0; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped: emitSkipped, + diagnostics: diagnostics || ts.emptyArray, + emittedFiles: emittedFiles, + sourceMaps: sourceMaps + }; + } + // In non Emit builder, clear affected files pending emit + else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) { + ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + // State can clear affected files pending emit if + if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared + // If every file pending emit is pending on only dts emit + || ts.every(state.affectedFilesPendingEmit, function (path, index) { + return index < state.affectedFilesPendingEmitIndex || + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; + })) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped: emitSkipped, - diagnostics: diagnostics || ts.emptyArray, - emittedFiles: emittedFiles, - sourceMaps: sourceMaps - }; } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** * Return the semantic diagnostics for the next affected file or undefined if iteration is complete @@ -120478,7 +120894,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { // Done return undefined; @@ -120490,7 +120906,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -120702,7 +121118,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -120759,7 +121175,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); @@ -120914,8 +121330,8 @@ var ts; !!redirectedReference; var seenNamesInFile = ts.createModeAwareCache(); var i = 0; - for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { - var entry = names_4[_i]; + for (var _i = 0, names_5 = names; _i < names_5.length; _i++) { + var entry = names_5[_i]; var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase(); // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant // they require calculating the mode for a given import from it's position in the resolution table, since a given @@ -121059,7 +121475,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -121236,7 +121652,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -121247,7 +121663,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -121387,7 +121803,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -121455,33 +121871,33 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { var _a; - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { return false; } @@ -121525,14 +121941,14 @@ var ts; if (options === void 0) { options = {}; } var info = getInfo(importingSourceFile.path, host); var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); }); } moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) { if (options === void 0) { options = {}; } var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { @@ -121589,7 +122005,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -121608,7 +122024,7 @@ var ts; var relativeSpecifiers; for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { var modulePath = modulePaths_1[_i]; - var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", @@ -121650,7 +122066,7 @@ var ts; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -121664,10 +122080,10 @@ var ts; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -121701,7 +122117,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -121709,7 +122125,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -121880,11 +122296,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -121925,23 +122341,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -121968,9 +122384,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -122001,7 +122417,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) { + function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) { var path = _a.path, isRedirect = _a.isRedirect; var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { @@ -122015,8 +122431,9 @@ var ts; var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; - var moduleFileNameForExtensionless = void 0; + var moduleFileName = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; @@ -122033,12 +122450,12 @@ var ts; isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) - moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) + moduleFileName = moduleFileToTry; // try with next level of directory packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -122066,7 +122483,7 @@ var ts; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); - if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` @@ -122090,13 +122507,13 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Ending.Minimal */, options), versionPaths.paths); if (fromPaths !== undefined) { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name - var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -122104,24 +122521,21 @@ var ts; } } } - return { moduleFileToTry: moduleFileToTry }; - } - function getExtensionlessFileName(path) { - // We still have a file name - remove the extension - var fullModulePathWithoutExtension = ts.removeFileExtension(path); - // If the file is /index, it can be imported by its directory name - // IFF there is not _also_ a file by the same name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + // No package.json exists; an index.js will still resolve as the package name + var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath }; + } } - return fullModulePathWithoutExtension; + return { moduleFileToTry: moduleFileToTry }; } } function tryGetAnyFileFromPath(host, path) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -122136,18 +122550,24 @@ var ts; return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } - function removeExtensionAndIndexPostFix(fileName, ending, options) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + function removeExtensionAndIndexPostFix(fileName, ending, options, host) { + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: - return ts.removeSuffix(noExtension, "/index"); - case 1 /* Index */: + case 0 /* Ending.Minimal */: + var withoutIndex = ts.removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + // Can't remove index if there's a file by the same name as the directory. + // Probably more callers should pass `host` so we can determine this? + return noExtension; + } + return withoutIndex; + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -122155,28 +122575,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -122258,8 +122678,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -122267,8 +122687,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -122291,7 +122711,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -122324,7 +122744,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -122337,7 +122757,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -122360,7 +122780,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -122387,9 +122807,9 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; @@ -122422,14 +122842,14 @@ var ts; var configFile = program.getCompilerOptions().configFile; if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs)) return undefined; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -122438,7 +122858,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -122562,7 +122982,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -122662,6 +123082,7 @@ var ts; createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -122721,6 +123142,7 @@ var ts; createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } ts.createProgramHost = createProgramHost; @@ -122809,6 +123231,7 @@ var ts; var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -122891,7 +123314,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -123047,10 +123470,10 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -123211,7 +123634,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -123271,7 +123694,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -123312,7 +123735,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -123553,7 +123976,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -123598,9 +124021,6 @@ var ts; function newer(date1, date2) { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); - } /*@internal*/ function isCircularBuildOrder(buildOrder) { return !!buildOrder && !!buildOrder.buildOrder; @@ -123616,8 +124036,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -124163,7 +124583,7 @@ var ts; outputFiles.forEach(function (_a) { var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; var priorChangeTime; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && ts.isDeclarationFileName(name)) { // Check for unchanged .d.ts files if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); @@ -124392,7 +124812,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -124421,7 +124841,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -124449,7 +124869,7 @@ var ts; if (!host.fileExists(inputFile)) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (!force) { @@ -124504,7 +124924,7 @@ var ts; // In addition to file timestamps, we also keep track of when a .d.ts file // had its file touched but not had its contents changed - this allows us // to skip a downstream typecheck - if (isDeclarationFile(output)) { + if (ts.isDeclarationFileName(output)) { var outputModifiedTime = ts.getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -124658,7 +125078,7 @@ var ts; reportVerbose = false; reportStatus(state, verboseMessage, proj.options.configFilePath); } - if (isDeclarationFile(file)) { + if (ts.isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); @@ -124808,7 +125228,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -124911,7 +125331,7 @@ var ts; if (!state.watch || !state.lastCachedPackageJsonLookups) return; ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { - createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, onDeleteValue: ts.closeFileWatcher, }); } @@ -125146,7 +125566,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -125157,7 +125577,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -125210,7 +125630,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -125283,7 +125703,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -125297,7 +125717,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -125306,7 +125726,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -125328,7 +125748,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -125356,7 +125776,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -125372,7 +125792,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -125391,12 +125811,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -125422,7 +125842,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -125450,16 +125870,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -125467,20 +125887,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -125491,17 +125911,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -125656,6 +126076,17 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + // Do not change existing values, as they exist in telemetry. + var CompletionInfoFlags; + (function (CompletionInfoFlags) { + CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports"; + CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion"; + CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets"; + })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {})); var OutliningSpanKind; (function (OutliningSpanKind) { /** Single or multi-line comments */ @@ -125862,7 +126293,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -125873,66 +126304,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -125940,7 +126371,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -125949,24 +126380,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -125974,11 +126405,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -125990,27 +126421,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -126019,17 +126450,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -126096,7 +126527,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -126157,22 +126588,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -126196,17 +126627,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -126214,108 +126645,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -126380,42 +126811,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -126424,66 +126855,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -126500,7 +126931,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -126543,13 +126974,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -126608,11 +127039,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -126702,30 +127133,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -126751,7 +127182,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -126767,13 +127198,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -126792,12 +127223,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -126805,13 +127236,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -126822,20 +127253,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -126850,29 +127281,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -126943,23 +127374,23 @@ var ts; // position and whose end is greater than the position. var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input if (nodeContainsPosition(children[middle])) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -126985,7 +127416,7 @@ var ts; return false; } var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -127054,7 +127485,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -127066,11 +127497,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -127095,7 +127526,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -127126,7 +127557,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -127162,25 +127593,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -127199,10 +127630,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -127211,17 +127642,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -127311,10 +127742,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -127324,56 +127755,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -127405,52 +127836,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -127458,7 +127889,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -127468,9 +127899,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -127483,18 +127914,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -127502,7 +127933,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -127525,8 +127956,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -127564,32 +127995,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -127598,7 +128029,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -127626,7 +128057,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -127641,7 +128072,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -127668,6 +128099,14 @@ var ts; return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } }); } ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost; + function moduleResolutionRespectsExports(moduleResolution) { + return moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports; + function moduleResolutionUsesNodeModules(moduleResolution) { + return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules; function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) { return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined; } @@ -127682,7 +128121,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -127691,25 +128130,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -127720,12 +128159,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -127769,7 +128208,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -127947,34 +128386,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -128051,7 +128490,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -128078,8 +128517,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -128129,22 +128568,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -128154,7 +128593,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -128182,10 +128621,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -128274,14 +128713,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -128300,7 +128739,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -128317,7 +128756,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -128374,7 +128813,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -128400,7 +128839,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -128408,15 +128847,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -128427,15 +128866,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -128444,10 +128883,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -128467,9 +128906,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -128481,48 +128920,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -128542,12 +128981,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -128571,7 +129010,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -128580,10 +129019,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -128707,16 +129146,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -128811,7 +129250,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -128931,20 +129370,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -128977,7 +129416,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -128995,7 +129434,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -129008,7 +129447,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -129028,7 +129467,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -129100,7 +129539,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -129109,7 +129548,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -129117,8 +129556,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -129207,9 +129646,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -129222,7 +129661,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -129271,8 +129710,8 @@ var ts; if (from === to) return false; var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {}); - if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) { - return cachedResult.isAutoImportable; + if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) { + return !cachedResult.isBlockedByPackageJsonDependencies; } var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); @@ -129286,7 +129725,7 @@ var ts; }); if (packageJsonFilter) { var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); - moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable); return isAutoImportable; } return hasImportablePath; @@ -129311,7 +129750,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -129348,24 +129787,31 @@ var ts; (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results"); var compilerOptions = program.getCompilerOptions(); var moduleCount = 0; - forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { - if (++moduleCount % 100 === 0) - cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); - var seenExports = new ts.Map(); - var checker = program.getTypeChecker(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - // Note: I think we shouldn't actually see resolved module symbols here, but weird merges - // can cause it to happen: see 'completionsImport_mergedReExport.ts' - if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); - } - checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { - if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + try { + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { + if (++moduleCount % 100 === 0) + cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); + var seenExports = new ts.Map(); + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + // Note: I think we shouldn't actually see resolved module symbols here, but weird merges + // can cause it to happen: see 'completionsImport_mergedReExport.ts' + if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } + checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); + } + }); }); - }); - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + } + catch (err) { + // Ensure cache is reset if operation is cancelled + cache.clear(); + throw err; + } + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -129384,10 +129830,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -129396,7 +129842,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -129406,8 +129852,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -129419,7 +129865,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -129429,15 +129875,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -129463,10 +129909,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -129502,68 +129948,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -129572,15 +130018,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -129594,59 +130040,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -129688,23 +130134,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -129718,10 +130164,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -129734,19 +130180,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -129754,47 +130200,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -129802,12 +130248,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -129815,36 +130261,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -129864,13 +130310,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -129895,10 +130341,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -129907,29 +130353,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -129938,35 +130384,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -129992,11 +130438,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -130018,12 +130464,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -130031,21 +130477,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -130054,7 +130500,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -130065,7 +130511,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -130074,7 +130520,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -130087,51 +130533,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -130150,7 +130596,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -130160,7 +130606,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -130185,9 +130631,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -130201,19 +130647,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -130221,7 +130667,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -130245,7 +130691,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -130272,10 +130718,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -130288,24 +130734,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -130316,97 +130762,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -130482,14 +130928,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -130501,13 +130947,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -130523,7 +130969,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -130532,38 +130978,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -130576,22 +131022,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -130601,17 +131047,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -130653,25 +131099,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -130702,19 +131148,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -130733,16 +131179,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -130758,20 +131204,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -130785,18 +131231,18 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { + case 196 /* SyntaxKind.LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -130808,21 +131254,21 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -130839,7 +131285,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -130852,41 +131298,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -130913,14 +131359,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -130929,10 +131375,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -130943,13 +131389,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -130971,11 +131417,11 @@ var ts; : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -130989,11 +131435,11 @@ var ts; } function isEmitResolutionKindUsingNodeModules(compilerOptions) { return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs || - ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function isEmitModuleResolutionRespectingExportMaps(compilerOptions) { - return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -131068,16 +131514,16 @@ var ts; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } var foundFileName = void 0; var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { + else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); foundFiles.set(foundFileName, outputExtension); } @@ -131087,7 +131533,7 @@ var ts; } } foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + result.push(nameAndKind(foundFile, "script" /* ScriptElementKind.scriptElement */, ext)); }); } // If possible, get folder completion as well @@ -131158,7 +131604,7 @@ var ts; var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -131169,7 +131615,7 @@ var ts; var _loop_4 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -131230,7 +131676,7 @@ var ts; }); ts.forEach(processedKeys, function (k) { if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(k, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }); return; @@ -131289,7 +131735,7 @@ var ts; var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); + return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* ScriptElementKind.scriptElement */, extension); }); var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); @@ -131334,7 +131780,7 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, names); @@ -131365,7 +131811,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -131407,14 +131853,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -131471,7 +131917,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -131513,16 +131959,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -131531,16 +131977,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -131553,7 +131999,7 @@ var ts; KeywordCompletionFilters[KeywordCompletionFilters["TypeAssertionKeywords"] = 6] = "TypeAssertionKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeywords"] = 7] = "TypeKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeyword"] = 8] = "TypeKeyword"; - KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 7] = "Last"; + KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 8] = "Last"; })(KeywordCompletionFilters || (KeywordCompletionFilters = {})); var GlobalsSearch; (function (GlobalsSearch) { @@ -131561,43 +132007,54 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) { + function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) { var _a, _b, _c; var start = ts.timestamp(); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - var resolutionLimitExceeded = false; + // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because + // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a + // relative path into node_modules), and we want to filter those completions out entirely. + // Import statement completions always need specifier resolution because the module specifier is + // part of their `insertText`, not the `codeActions` creating edits away from the cursor. + var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions())); + var skippedAny = false; var ambientCount = 0; var resolvedCount = 0; var resolvedFromCacheCount = 0; var cacheAttemptCount = 0; - var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var result = cb({ + tryResolve: tryResolve, + skippedAny: function () { return skippedAny; }, + resolvedAny: function () { return resolvedCount > 0; }, + resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, + }); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; - function tryResolve(exportInfo, isFromAmbientModule) { + function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { - var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences); + var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences); if (result_1) { ambientCount++; } - return result_1; + return result_1 || "failed"; } - var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; + var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit; var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache) - ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) + ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) : undefined; if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) { - resolutionLimitExceeded = true; + skippedAny = true; } resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0; - resolvedFromCacheCount += exportInfo.length - resolvedCount; + resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0); if (shouldGetModuleSpecifierFromCache) { cacheAttemptCount++; } - return result; + return result || (needsFullResolution ? "failed" : "skipped"); } } function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) { @@ -131617,7 +132074,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -131631,7 +132088,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -131639,21 +132096,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -131670,16 +132127,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -131692,9 +132149,10 @@ var ts; return undefined; var lowerCaseTokenText = location.text.toLowerCase(); var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken); - var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences, - /*isForImportStatementCompletion*/ false, function (context) { + var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences, + /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) { var entries = ts.mapDefined(previousResponse.entries, function (entry) { + var _a; if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) { // Not an auto import or already resolved; keep as is return entry; @@ -131705,10 +132163,14 @@ var ts; } var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin; var info = exportMap.get(file.path, entry.data.exportMapKey); - var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); - if (!result) + var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); + if (result === "skipped") return entry; - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + if (!result || result === "failed") { + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); + return undefined; + } + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -131716,12 +132178,13 @@ var ts; entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)]; return entry; }); - if (!context.resolutionLimitExceeded()) { + if (!context.skippedAny()) { previousResponse.isIncomplete = undefined; } return entries; }); previousResponse.entries = newEntries; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -131730,8 +132193,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -131745,25 +132208,25 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; @@ -131776,17 +132239,17 @@ var ts; getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { + if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { return undefined; } getCompletionEntriesFromSymbols(symbols, entries, /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); } - if (keywordFilters !== 0 /* None */) { + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (!entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } @@ -131803,12 +132266,13 @@ var ts; ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); } return { + flags: completionData.flags, isGlobalCompletion: isInSnippetScope, isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, optionalReplacementSpan: getOptionalReplacementSpan(location), - entries: entries + entries: entries, }; } function isUncheckedFile(sourceFile, compilerOptions) { @@ -131816,9 +132280,9 @@ var ts; } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -131828,12 +132292,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -131852,14 +132316,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -131878,7 +132342,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -131891,7 +132355,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -131908,18 +132372,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -131930,7 +132394,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -131943,8 +132407,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -131954,12 +132418,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -131970,28 +132434,24 @@ var ts; } } if (origin && originIsObjectLiteralMethod(origin)) { - var importAdder = void 0; - (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails); + (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails); if (!preferences.useLabelDetailsInCompletionEntries) { name = name + labelDetails.detail; labelDetails = undefined; } source = CompletionSource.ObjectLiteralMethodSnippet; sortText = Completions.SortText.SortBelow(sortText); - if (importAdder.hasFixes()) { - hasAction = true; - } } if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -132000,7 +132460,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -132042,8 +132502,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -132102,16 +132562,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -132122,13 +132582,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -132139,9 +132599,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -132156,9 +132616,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -132203,8 +132663,7 @@ var ts; var isSnippet = preferences.includeCompletionsWithSnippetText || undefined; var insertText = name; var sourceFile = enclosingDeclaration.getSourceFile(); - var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host); - var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder); + var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences); if (!method) { return undefined; } @@ -132216,10 +132675,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -132232,33 +132691,32 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; - return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; + return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; - function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) { + function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } var checker = program.getTypeChecker(); - var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var declaration = declarations[0]; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -132266,7 +132724,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -132275,47 +132733,72 @@ var ts; if (!typeNode || !ts.isFunctionTypeNode(typeNode)) { return undefined; } - var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); - if (importableReference) { - typeNode = importableReference.typeNode; - ts.codefix.importSymbols(importAdder, importableReference.symbols); - } var body = void 0; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } + var parameters = typeNode.parameters.map(function (typedParam) { + return ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken, + /*type*/ undefined, typedParam.initializer); + }); return ts.factory.createMethodDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, - /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body); + /*questionToken*/ undefined, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } default: return undefined; } } function createSnippetPrinter(printerOptions) { + var escapes; var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions)); var printer = ts.createPrinter(printerOptions, baseWriter); - var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } }); + var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } }); return { printSnippetList: printSnippetList, printAndFormatSnippetList: printAndFormatSnippetList, }; + // The formatter/scanner will have issues with snippet-escaped text, + // so instead of writing the escaped text directly to the writer, + // generate a set of changes that can be applied to the unescaped text + // to escape it post-formatting. + function escapingWrite(s, write) { + var escaped = ts.escapeSnippetText(s); + if (escaped !== s) { + var start = baseWriter.getTextPos(); + write(); + var end = baseWriter.getTextPos(); + escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } }); + } + else { + write(); + } + } /* Snippet-escaping version of `printer.printList`. */ function printSnippetList(format, list, sourceFile) { + var unescaped = printUnescapedSnippetList(format, list, sourceFile); + return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped; + } + function printUnescapedSnippetList(format, list, sourceFile) { + escapes = undefined; writer.clear(); printer.writeList(format, list, sourceFile, writer); return writer.getText(); } function printAndFormatSnippetList(format, list, sourceFile, formatContext) { var syntheticFile = { - text: printSnippetList(format, list, sourceFile), + text: printUnescapedSnippetList(format, list, sourceFile), getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); }, @@ -132327,7 +132810,10 @@ var ts; /* indentation */ 0, /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions })); }); - return ts.textChanges.applyChanges(syntheticFile.text, changes); + var allChanges = escapes + ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); }) + : changes; + return ts.textChanges.applyChanges(syntheticFile.text, allChanges); } } function originToCompletionEntryData(origin) { @@ -132353,11 +132839,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -132369,7 +132855,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -132385,21 +132871,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -132410,7 +132896,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -132419,10 +132905,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -132441,7 +132927,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -132494,7 +132980,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -132502,7 +132988,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -132526,8 +133012,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -132558,7 +133044,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -132572,8 +133058,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -132593,14 +133079,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -132612,22 +133098,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -132656,20 +133142,6 @@ var ts; }; } } - if (source === CompletionSource.ObjectLiteralMethodSnippet) { - var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken); - var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder; - if (importAdder.hasFixes()) { - var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes); - return { - sourceDisplay: undefined, - codeActions: [{ - changes: changes, - description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]), - }], - }; - } - } if (originIsTypeOnlyAlias(origin)) { var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences); ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias"); @@ -132681,7 +133153,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -132713,7 +133185,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -132721,31 +133193,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -132753,14 +133225,14 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -132776,10 +133248,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -132800,7 +133272,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -132810,21 +133282,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -132855,15 +133327,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -132876,6 +133349,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -132885,11 +133359,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -132897,7 +133371,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -132905,18 +133379,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -132924,58 +133398,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -132983,16 +133457,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -133001,7 +133475,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -133020,8 +133494,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -133029,8 +133503,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -133044,10 +133518,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -133068,16 +133542,17 @@ var ts; isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, + flags: flags, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -133086,13 +133561,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -133107,7 +133582,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -133115,7 +133590,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -133129,7 +133604,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -133143,7 +133618,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -133167,7 +133642,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -133175,7 +133650,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; if (inUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -133222,21 +133697,21 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, symbol: firstAccessibleSymbol, targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags, - }], sourceFile, program, host, preferences) || {}).moduleSpecifier; + }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -133267,15 +133742,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -133291,44 +133766,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -133363,7 +133838,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -133373,21 +133848,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -133396,8 +133871,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -133421,10 +133896,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -133440,29 +133915,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -133477,6 +133952,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -133488,50 +133964,72 @@ var ts; var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken); var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host); var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host); - resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) { + resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) { exportInfo.search(sourceFile.path, /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) { if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings()))) return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText); }, function (info, symbolName, isFromAmbientModule, exportMapKey) { + var _a; if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) { return; } - var defaultExportInfo = ts.find(info, isImportableExportInfo); - if (!defaultExportInfo) { + // Do a relatively cheap check to bail early if all re-exports are non-importable + // due to file location or package.json dependency filtering. For non-node16+ + // module resolution modes, getting past this point guarantees that we'll be + // able to generate a suitable module specifier, so we can safely show a completion, + // even if we defer computing the module specifier. + var firstImportableExportInfo = ts.find(info, isImportableExportInfo); + if (!firstImportableExportInfo) { return; } - // If we don't need to resolve module specifiers, we can use any re-export that is importable at all - // (We need to ensure that at least one is importable to show a completion.) - var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier; - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + // In node16+, module specifier resolution can fail due to modules being blocked + // by package.json `exports`. If that happens, don't show a completion item. + // N.B. in this resolution mode we always try to resolve module specifiers here, + // because we have to know now if it's going to fail so we can omit the completion + // from the list. + var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {}; + if (result === "failed") + return; + // If we skipped resolving module specifiers, our selection of which ExportInfo + // to use here is arbitrary, since the info shown in the completion list derived from + // it should be identical regardless of which one is used. During the subsequent + // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick + // the best one based on the module specifier it produces. + var exportInfo = firstImportableExportInfo, moduleSpecifier; + if (result !== "skipped") { + (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); + } + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, isFromPackageJson: exportInfo.isFromPackageJson, }); }); - hasUnresolvedAutoImports = context.resolutionLimitExceeded(); + hasUnresolvedAutoImports = context.skippedAny(); + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -133568,7 +134066,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -133578,7 +134076,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -133593,7 +134092,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -133620,27 +134119,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -133651,45 +134150,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -133708,21 +134207,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -133734,22 +134233,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -133759,12 +134258,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -133775,19 +134274,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -133799,14 +134298,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -133823,38 +134322,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -133867,14 +134366,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -133883,7 +134382,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -133892,48 +134391,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -133947,8 +134446,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -133978,23 +134477,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134005,8 +134504,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134014,10 +134513,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134025,7 +134524,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134044,75 +134543,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -134133,21 +134632,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -134156,7 +134655,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -134167,7 +134666,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -134183,22 +134682,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -134216,13 +134715,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -134235,7 +134734,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -134269,7 +134768,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -134294,7 +134793,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -134313,10 +134812,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -134324,11 +134823,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -134339,7 +134838,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -134358,7 +134857,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -134381,15 +134880,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -134412,12 +134911,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -134426,27 +134925,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -134456,11 +134955,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -134469,7 +134968,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 7 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -134478,30 +134977,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -134509,63 +135008,63 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -134586,9 +135085,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -134604,7 +135103,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -134626,7 +135125,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -134634,7 +135133,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -134652,15 +135151,15 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -134674,22 +135173,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -134700,7 +135199,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -134709,15 +135208,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -134734,11 +135233,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -134760,13 +135259,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -134779,22 +135278,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -134802,7 +135301,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -134819,7 +135318,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -134827,23 +135326,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -134853,12 +135352,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -134898,8 +135397,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -134936,8 +135435,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -134951,7 +135450,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -134981,7 +135480,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -135011,45 +135510,47 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); + case 101 /* SyntaxKind.InKeyword */: + return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -135091,7 +135592,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -135123,16 +135624,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -135148,41 +135649,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -135201,12 +135702,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -135214,7 +135715,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -135223,13 +135724,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -135237,13 +135738,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -135251,13 +135752,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -135268,13 +135769,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -135286,11 +135787,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -135302,13 +135803,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -135323,7 +135824,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -135342,7 +135843,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -135357,7 +135858,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -135377,10 +135878,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -135464,7 +135965,7 @@ var ts; } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { @@ -135472,7 +135973,7 @@ var ts; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); var sourceFileOptions = { languageVersion: scriptTarget, impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), @@ -135485,15 +135986,15 @@ var ts; // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). - var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) && + var otherBucketKey = !ts.isDeclarationFileName(path) && ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); } } var bucketEntry = bucket.get(path); @@ -135607,18 +136108,18 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -135685,43 +136186,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -135730,7 +136231,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -135752,18 +136253,18 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* SyntaxKind.ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -135785,7 +136286,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -135819,33 +136320,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -135854,12 +136355,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -135870,7 +136371,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -135882,7 +136383,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -135907,7 +136408,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -135916,7 +136417,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -135936,7 +136437,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -135984,7 +136485,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -135999,15 +136500,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -136032,7 +136533,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -136045,21 +136546,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -136077,24 +136578,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -136121,22 +136622,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -136166,16 +136667,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; @@ -136205,7 +136706,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -136216,21 +136717,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -136257,7 +136758,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -136285,7 +136786,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -136324,7 +136825,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -136333,7 +136834,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -136341,28 +136842,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -136403,7 +136904,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -136420,19 +136921,19 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } else { @@ -136455,18 +136956,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -136474,7 +136975,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -136493,7 +136994,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -136501,32 +137002,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -136534,7 +137035,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -136557,19 +137058,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -136579,7 +137080,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -136587,10 +137088,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -136624,12 +137125,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -136637,16 +137138,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -136655,17 +137156,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -136680,14 +137181,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -136695,9 +137196,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -136708,50 +137209,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -136780,7 +137281,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -136802,7 +137303,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -136812,11 +137313,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -136827,10 +137328,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -136858,7 +137359,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -136878,10 +137379,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -136909,13 +137410,13 @@ var ts; continue; } var _loop_5 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -136946,7 +137447,7 @@ var ts; return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -136967,7 +137468,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -136977,21 +137478,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -136999,41 +137500,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -137049,7 +137550,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -137058,20 +137559,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -137094,17 +137595,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -137117,10 +137618,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -137134,7 +137635,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -137186,7 +137687,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -137209,7 +137710,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -137217,7 +137718,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -137248,19 +137749,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -137273,7 +137774,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -137301,13 +137802,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -137317,7 +137818,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -137343,17 +137844,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -137370,7 +137871,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -137382,7 +137883,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -137430,6 +137931,30 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function getTopMostDeclarationNamesInFile(declarationName, sourceFile) { + var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); }); + return candidates.reduce(function (topMost, decl) { + var depth = getDepth(decl); + if (!ts.some(topMost.declarationNames) || depth === topMost.depth) { + topMost.declarationNames.push(decl); + topMost.depth = depth; + } + else if (depth < topMost.depth) { + topMost.declarationNames = [decl]; + topMost.depth = depth; + } + return topMost; + }, { depth: Infinity, declarationNames: [] }).declarationNames; + function getDepth(declaration) { + var depth = 0; + while (declaration) { + declaration = ts.getContainerNode(declaration); + depth++; + } + return depth; + } + } + Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile; function someSignatureUsage(signature, sourceFiles, checker, cb) { if (!signature.name || !ts.isIdentifier(signature.name)) return false; @@ -137477,8 +138002,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -137493,27 +138018,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -137529,7 +138054,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -137540,7 +138065,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -137591,7 +138116,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -137601,14 +138126,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -137616,7 +138141,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -137636,7 +138161,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -137646,7 +138171,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -137657,9 +138182,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -137667,7 +138192,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -137694,11 +138219,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -137718,14 +138243,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -137743,7 +138268,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -137759,7 +138284,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -137770,7 +138295,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -137789,18 +138314,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -137811,7 +138336,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -137821,10 +138346,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -137848,10 +138373,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -137871,7 +138396,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -137899,13 +138424,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -137956,15 +138481,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -137973,7 +138498,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -137982,46 +138507,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -138029,26 +138554,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -138061,18 +138586,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -138117,30 +138642,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -138150,14 +138675,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -138172,7 +138697,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -138180,7 +138705,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -138192,13 +138717,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -138220,7 +138745,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -138234,12 +138759,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -138249,7 +138774,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -138289,7 +138814,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -138300,7 +138825,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -138329,12 +138854,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -138354,7 +138879,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -138403,7 +138928,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -138427,8 +138952,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -138448,7 +138973,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -138461,16 +138986,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -138568,7 +139093,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -138579,7 +139104,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -138609,7 +139134,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -138639,7 +139164,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -138667,7 +139192,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -138684,59 +139209,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -138753,7 +139278,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -138792,25 +139317,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -138826,7 +139351,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -139066,7 +139591,9 @@ var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { - function getDefinitionAtPosition(program, sourceFile, position) { + function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) { + var _a; + var _b; var resolvedRef = getReferenceAtPosition(sourceFile, position, program); var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { @@ -139079,45 +139606,75 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; - var symbol_1 = getSymbol(classDecl, typeChecker); + var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution; var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration); var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : ""; var sourceFile_1 = node.getSourceFile(); return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } - var symbol = getSymbol(node, typeChecker); + var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; + var fallbackNode = node; + if (searchOtherFilesOnly && failedAliasResolution) { + // We couldn't resolve the specific import, try on the module specifier. + var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); }); + var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration); + if (moduleSpecifier) { + (_a = getSymbol(moduleSpecifier, typeChecker, stopAtAlias), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution); + fallbackNode = moduleSpecifier; + } + } + if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) { + // We couldn't resolve the module specifier as an external module, but it could + // be that module resolution succeeded but the target was not a module. + var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode)); + if (ref) { + return [{ + name: fallbackNode.text, + fileName: ref.resolvedFileName, + containerName: undefined, + containerKind: undefined, + kind: "script" /* ScriptElementKind.scriptElement */, + textSpan: ts.createTextSpan(0, 0), + failedAliasResolution: failedAliasResolution, + isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), + unverified: fallbackNode !== node, + }]; + } + } // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } + if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; })) + return undefined; var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) { - var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); + var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) { return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -139125,9 +139682,9 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray; + var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the @@ -139150,7 +139707,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -139248,24 +139805,24 @@ var ts; return undefined; } if (ts.isImportMeta(node.parent) && node.parent.name === node) { - return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent); + return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false); } - var symbol = getSymbol(node, typeChecker); + var _a = getSymbol(node, typeChecker, /*stopAtAlias*/ false), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution; if (!symbol) return undefined; var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node); var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker); - var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node); + var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution); // If a function returns 'void' or some other type with no definition, just return the function definition. - var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node); + var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; - function definitionFromType(type, checker, node) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { - return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node); + function definitionFromType(type, checker, node, failedAliasResolution) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { + return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } function tryGetReturnTypeOfFunction(symbol, type, checker) { @@ -139301,19 +139858,23 @@ var ts; function getDefinitionInfoForIndexSignatures(node, checker) { return ts.mapDefined(checker.getIndexInfosAtLocation(node), function (info) { return info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); }); } - function getSymbol(node, checker) { + function getSymbol(node, checker, stopAtAlias) { var symbol = checker.getSymbolAtLocation(node); // If this is an alias, and the request came at the declaration location // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + var failedAliasResolution = false; + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { - return aliased; + return { symbol: aliased }; + } + else { + failedAliasResolution = true; } } - return symbol; + return { symbol: symbol, failedAliasResolution: failedAliasResolution }; } // Go to the original declaration for cases: // @@ -139321,36 +139882,55 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - switch (declaration.kind) { - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: - return true; - case 270 /* ImportSpecifier */: - return declaration.parent.kind === 269 /* NamedImports */; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); - default: - return false; + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { + return false; } + return true; + } + /** + * ```ts + * function f() {} + * f.foo = 0; + * ``` + * + * Here, `f` has two declarations: the function declaration, and the identifier in the next line. + * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so + * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a + * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this + * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the + * declaration looks like an assignment, that declaration is in no sense a definition for `f`. + * But that information is totally lost during binding and/or symbol merging, so we need to do + * our best to reconstruct it or use other heuristics. This function (and the logic around its + * calling) covers our tests but feels like a hack, and it would be great if someone could come + * up with a more precise definition of what counts as a definition. + */ + function isExpandoDeclaration(node) { + if (!ts.isAssignmentDeclaration(node)) + return false; + var containingAssignment = ts.findAncestor(node, function (p) { + if (ts.isAssignmentExpression(p)) + return true; + if (!ts.isAssignmentDeclaration(p)) + return "quit"; + return false; + }); + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; } - function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { - // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties. - // For deduping purposes, we also want to exclude any declarationNodes if provided. - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) - || undefined; - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); + var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); }); + var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -139370,26 +139950,27 @@ var ts; return declarations.length ? declarationsWithBody.length !== 0 ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) - : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)] : undefined; } } /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ - function createDefinitionInfo(declaration, checker, symbol, node) { + function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) { var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node); var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : ""; - return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName); + return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution); } + GoToDefinition.createDefinitionInfo = createDefinitionInfo; /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) { + function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) { var sourceFile = declaration.getSourceFile(); if (!textSpan) { var name = ts.getNameOfDeclaration(declaration) || declaration; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -139401,29 +139982,29 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; } } - function createDefinitionFromSignatureDeclaration(typeChecker, decl) { - return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); + function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) { + return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution); } function findReferenceInPosition(refs, pos) { return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); @@ -139433,7 +140014,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -139454,9 +140035,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -139568,10 +140149,10 @@ var ts; // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = getDisplayPartsFromComment(jsdoc.comment, checker); @@ -139588,11 +140169,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -139606,8 +140187,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -139622,17 +140203,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -139646,7 +140227,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -139654,13 +140235,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -139687,14 +140268,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -139704,7 +140285,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -139715,8 +140296,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -139726,7 +140307,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139752,14 +140333,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139846,37 +140427,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -139886,25 +140467,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -139917,14 +140498,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -139983,9 +140564,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -139995,7 +140576,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -140012,7 +140593,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -140046,7 +140627,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -140229,7 +140810,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -140242,7 +140823,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -140254,25 +140835,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -140284,7 +140865,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -140295,17 +140876,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -140315,7 +140896,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -140323,11 +140904,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -140337,9 +140918,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -140347,10 +140928,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -140364,27 +140945,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -140398,7 +140979,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -140418,10 +140999,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -140434,7 +141015,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -140452,9 +141033,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -140510,16 +141091,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -140527,10 +141108,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -140596,7 +141177,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -140615,12 +141196,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -140628,7 +141209,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -140642,7 +141223,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -140672,7 +141253,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -140681,53 +141262,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -140760,19 +141341,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -140782,10 +141363,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -140847,7 +141428,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -140861,13 +141442,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -140882,7 +141463,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -140890,7 +141471,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -140901,10 +141482,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -140917,7 +141498,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -140925,9 +141506,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -141041,7 +141622,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -141059,7 +141640,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -141328,11 +141909,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -141371,19 +141952,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -141436,7 +142017,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -141444,7 +142025,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -141494,7 +142075,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -141529,7 +142110,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -141545,9 +142126,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -141558,7 +142139,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -141572,7 +142153,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -141580,23 +142161,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -141604,52 +142185,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -141660,33 +142241,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -141695,32 +142276,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -141730,12 +142311,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -141861,7 +142442,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -141913,7 +142494,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -141990,10 +142571,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -142003,10 +142584,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -142031,10 +142612,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -142043,10 +142624,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -142115,35 +142696,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -142204,7 +142785,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -142225,10 +142806,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -142258,12 +142839,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -142275,54 +142856,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -142331,18 +142912,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -142350,15 +142931,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -142374,31 +142955,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -142406,31 +142987,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -142444,12 +143025,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -142460,16 +143041,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -142478,15 +143059,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -142514,31 +143095,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -142625,13 +143206,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -142644,14 +143225,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -142660,7 +143241,7 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { @@ -142671,7 +143252,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -142681,7 +143262,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -142711,13 +143292,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -142749,7 +143330,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -142817,7 +143398,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -142874,26 +143455,26 @@ var ts; if (ts.isMappedTypeNode(node)) { var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -142905,7 +143486,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -142918,14 +143499,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -142981,7 +143562,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -142996,25 +143577,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -143061,7 +143642,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -143075,27 +143656,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -143105,20 +143686,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -143154,7 +143735,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -143171,7 +143752,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -143214,7 +143795,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -143224,10 +143805,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -143252,7 +143833,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -143262,7 +143843,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -143291,28 +143872,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -143322,7 +143903,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -143344,7 +143925,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -143363,8 +143944,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -143402,7 +143983,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -143433,7 +144014,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -143445,7 +144026,7 @@ var ts; var _loop_9 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; @@ -143465,17 +144046,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -143532,10 +144113,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -143568,9 +144149,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -143578,33 +144159,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -143617,7 +144198,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -143638,14 +144219,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -143681,25 +144262,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -143713,7 +144294,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name)) { @@ -143785,17 +144366,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -143804,7 +144385,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -143827,7 +144408,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -143869,13 +144450,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -143937,7 +144518,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -144046,7 +144627,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -144082,7 +144663,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -144104,16 +144685,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -144125,12 +144706,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -144200,26 +144781,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -144232,28 +144813,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -144266,32 +144847,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -144299,52 +144880,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -144352,23 +144933,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -144378,10 +144959,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -144389,10 +144970,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -144403,41 +144984,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -144457,7 +145038,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -144465,21 +145046,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -144488,29 +145069,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -144520,31 +145101,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -144554,63 +145135,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -144621,7 +145202,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -144629,21 +145210,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -144651,22 +145232,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -144675,7 +145256,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -144691,42 +145272,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -144736,30 +145317,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144770,17 +145351,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -144796,14 +145377,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -144854,23 +145435,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -144885,31 +145466,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -144921,7 +145502,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144933,16 +145514,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -145147,8 +145728,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -145166,8 +145747,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -145179,7 +145760,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -145207,7 +145788,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -145235,11 +145816,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -145247,12 +145828,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -145261,29 +145842,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -145315,7 +145896,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -145326,40 +145907,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -145368,15 +145949,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -145443,8 +146024,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -145456,263 +146037,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -145730,7 +146311,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -145771,54 +146352,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -145830,22 +146411,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -145871,34 +146452,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -145907,40 +146488,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -145949,71 +146530,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -146028,45 +146609,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -146077,28 +146658,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -146120,15 +146701,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -146137,25 +146718,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -146184,17 +146765,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -146243,12 +146824,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -146274,7 +146855,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -146343,16 +146924,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -146374,12 +146955,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -146387,7 +146968,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -146396,7 +146977,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -146436,17 +147017,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -146543,11 +147124,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -146561,7 +147142,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -146589,7 +147170,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -146634,7 +147215,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -146649,7 +147230,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -146662,8 +147243,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -146686,19 +147267,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -146713,12 +147294,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -146745,26 +147326,26 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: - case 228 /* ExpressionWithTypeArguments */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -146799,7 +147380,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -146812,6 +147393,9 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + if (ts.nodeIsMissing(child)) { + return inheritedIndentation; + } var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; var undecoratedChildStartLine = childStartLine; @@ -146819,10 +147403,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -146858,17 +147442,17 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -146878,7 +147462,14 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; - if (listStartToken !== 0 /* Unknown */) { + // node range is outside the target range - do not dive inside + if (!ts.rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { + if (nodes.end < originalRange.pos) { + formattingScanner.skipToEndOf(nodes); + } + return; + } + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -146891,7 +147482,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -146910,15 +147501,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */ && ts.isCallLikeExpression(parent)) { var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; if (startLine !== commaTokenLine) { formattingScanner.advance(); @@ -146942,7 +147533,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -146952,13 +147543,13 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } @@ -146968,15 +147559,15 @@ var ts; if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -146990,19 +147581,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -147020,7 +147611,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -147041,7 +147632,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -147049,14 +147640,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -147065,15 +147656,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -147099,7 +147690,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -147230,48 +147821,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -147313,53 +147904,53 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -147445,7 +148036,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -147481,21 +148072,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -147515,7 +148106,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -147540,9 +148131,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -147551,7 +148142,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -147605,12 +148196,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -147649,7 +148240,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -147660,9 +148251,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -147675,13 +148266,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -147691,9 +148282,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -147708,8 +148299,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -147789,42 +148380,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -147842,27 +148433,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -147871,7 +148462,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -147881,7 +148472,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -147902,7 +148493,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -147918,98 +148509,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -148020,11 +148611,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -148114,7 +148705,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -148198,7 +148789,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -148241,7 +148832,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -148347,7 +148938,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -148411,7 +149002,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -148464,7 +149055,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -148473,19 +149064,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -148626,8 +149217,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -148635,22 +149226,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -148659,28 +149250,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -148735,7 +149326,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -148752,12 +149343,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -148780,7 +149371,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -148857,10 +149448,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -148872,16 +149463,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -148890,8 +149481,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -148911,7 +149502,7 @@ var ts; var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); var _loop_12 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. @@ -148938,8 +149529,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -148994,7 +149585,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -149002,7 +149593,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -149012,7 +149603,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -149223,7 +149814,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -149263,7 +149854,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -149275,18 +149866,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -149297,17 +149888,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -149315,13 +149906,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -149330,17 +149921,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -149369,7 +149960,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -149391,15 +149982,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -149408,14 +149999,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -149602,8 +150193,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -149688,7 +150279,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -149738,7 +150329,7 @@ var ts; ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, - ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, + ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code, @@ -149832,12 +150423,12 @@ var ts; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -149905,15 +150496,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -150002,7 +150593,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -150026,16 +150617,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -150049,9 +150640,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -150061,10 +150652,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -150099,9 +150690,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -150216,7 +150807,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -150256,7 +150847,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -150309,9 +150900,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -150321,7 +150912,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -150336,30 +150927,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -150376,13 +150967,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -150420,11 +151011,11 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -150451,7 +151042,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -150484,14 +151075,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -150542,7 +151133,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -150561,7 +151152,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -150613,7 +151204,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150624,14 +151215,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150648,7 +151239,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150659,7 +151250,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150686,7 +151277,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -150747,7 +151338,7 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options); + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, options); var _loop_14 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { @@ -150822,7 +151413,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -150885,7 +151476,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -150966,7 +151557,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -150975,7 +151566,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -150995,7 +151586,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -151011,10 +151602,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -151024,7 +151615,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -151129,12 +151720,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -151150,11 +151741,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -151164,7 +151755,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -151175,8 +151766,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -151278,7 +151869,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -151295,7 +151886,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -151305,7 +151896,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -151387,12 +151978,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -151413,10 +152004,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -151454,10 +152045,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -151497,9 +152088,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -151517,29 +152108,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -151586,8 +152177,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -151595,11 +152186,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -151638,19 +152229,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -151679,8 +152270,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -151695,23 +152286,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -151719,10 +152310,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -151742,7 +152333,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -151757,7 +152348,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -151768,7 +152359,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -151779,10 +152370,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -151839,7 +152430,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -151861,11 +152452,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -151889,7 +152480,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -151919,7 +152510,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -151979,7 +152570,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -152148,7 +152739,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -152161,10 +152752,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -152260,7 +152851,7 @@ var ts; var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider); var useRequire = shouldUseRequire(sourceFile, program); - var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); + var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); if (fix) { addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined }); } @@ -152270,20 +152861,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -152296,32 +152887,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -152349,13 +152940,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -152365,7 +152956,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -152430,7 +153021,7 @@ var ts; : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences)); + var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences)); return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, @@ -152443,13 +153034,13 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; - function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host); + return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; @@ -152471,7 +153062,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -152494,7 +153085,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -152504,25 +153095,32 @@ var ts; return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); } } - function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { - var _a = getNewImportFixes(program, importingFile, - /*position*/ undefined, - /*isValidTypeOnlyUseSite*/ false, - /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; + function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { + var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, + /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host); return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount }); } codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; - function getImportFixes(exportInfos, symbolName, + function getImportFixes(exportInfos, useNamespaceInfo, /** undefined only for missing JSX namespace */ - position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) { + isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) { var checker = program.getTypeChecker(); var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); - var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); + var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker); var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions()); - // 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, position, isValidTypeOnlyUseSite, useRequire, host, preferences); - return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true); + if (addToExisting) { + // Don't bother providing an action to add a new import if we can add to an existing one. + return { + computedWithoutCacheCount: 0, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false), + }; + } + var _a = getFixesForAddImport(exportInfos, existingImports, program, sourceFile, useNamespaceInfo === null || useNamespaceInfo === void 0 ? void 0 : useNamespaceInfo.position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly), fixes = _a.fixes, _b = _a.computedWithoutCacheCount, computedWithoutCacheCount = _b === void 0 ? 0 : _b; + return { + computedWithoutCacheCount: computedWithoutCacheCount, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true), + }; } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -152538,13 +153136,14 @@ var ts; // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. return ts.firstDefined(existingImports, function (_a) { + var _b; var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -152552,11 +153151,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -152566,11 +153165,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -152579,31 +153178,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -152612,22 +153211,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -152638,7 +153237,7 @@ var ts; function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { @@ -152646,7 +153245,7 @@ var ts; if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } - if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } }); @@ -152684,6 +153283,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); }); + var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions)); var getModuleSpecifiers = fromCacheOnly ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); } : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); }; @@ -152691,38 +153291,39 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; - return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) { - // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return !importedSymbolHasValueMeaning && isJs && position !== undefined - ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } - : { - kind: 3 /* AddNew */, - moduleSpecifier: moduleSpecifier, - importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), - useRequire: useRequire, - addAsTypeOnly: addAsTypeOnly, - exportInfo: exportInfo, - isReExport: i > 0, - }; + return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { + return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : + // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + { + kind: 3 /* ImportFixKind.AddNew */, + moduleSpecifier: moduleSpecifier, + importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), + useRequire: useRequire, + addAsTypeOnly: addAsTypeOnly, + exportInfo: exportInfo, + isReExport: i > 0, + }; }); }); return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes }; } - function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); }); - return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes; + return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly); } function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) { + var _b; var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -152753,23 +153354,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -152792,10 +153393,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -152806,9 +153407,10 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences); + var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; + var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text }; } function getUmdSymbol(token, checker) { @@ -152819,7 +153421,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -152828,10 +153430,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -152839,7 +153441,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -152848,9 +153450,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -152858,12 +153460,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; - case ts.ModuleKind.Node12: + return 2 /* ImportKind.Namespace */; + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -152872,7 +153474,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -152880,19 +153482,19 @@ var ts; var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes; })); return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text }; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -152907,8 +153509,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -152940,7 +153542,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -152951,14 +153553,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -152967,12 +153569,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -152983,45 +153585,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -153029,7 +153631,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -153047,13 +153649,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -153065,7 +153667,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -153075,7 +153677,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -153084,7 +153686,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -153094,7 +153696,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -153145,7 +153747,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -153169,11 +153771,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -153182,12 +153784,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) @@ -153228,7 +153830,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -153265,7 +153867,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -153399,7 +154001,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -153407,19 +154009,19 @@ var ts; changeTracker.filterJSDocTags(sourceFile, classElement, ts.not(ts.isJSDocOverrideTag)); return; } - var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* OverrideKeyword */; }); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* SyntaxKind.OverrideKeyword */; }); ts.Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -153461,7 +154063,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -153501,7 +154103,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -153520,7 +154122,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -153551,7 +154153,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -153560,16 +154162,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -153635,18 +154237,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -153664,7 +154266,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -153697,14 +154299,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -153776,7 +154378,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -153835,7 +154437,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -153879,19 +154481,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -153953,19 +154555,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -153983,20 +154585,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -154020,15 +154622,15 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; @@ -154055,12 +154657,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -154069,7 +154671,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -154077,17 +154679,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -154099,13 +154701,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -154119,15 +154721,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -154143,18 +154745,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -154191,32 +154793,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -154244,7 +154846,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -154269,15 +154871,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -154297,7 +154899,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.decorators, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -154307,7 +154909,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } function addJsxAttributes(changes, context, info) { @@ -154335,7 +154937,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop)); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* QuotePreference.Single */), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -154345,42 +154947,42 @@ var ts; changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -154394,17 +154996,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -154419,8 +155021,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -154444,7 +155046,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -154529,7 +155131,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -154604,7 +155206,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -154647,7 +155249,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -154772,8 +155374,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { var compilerOptions = context.program.getCompilerOptions(); @@ -154791,7 +155393,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -154870,17 +155472,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -154977,7 +155579,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -155084,7 +155686,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -155099,7 +155701,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -155111,11 +155713,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -155123,7 +155725,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -155132,7 +155734,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -155168,7 +155770,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -155210,7 +155812,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -155252,13 +155854,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -155281,7 +155883,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -155292,7 +155894,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -155301,18 +155903,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -155321,15 +155923,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -155337,14 +155939,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -155394,8 +155996,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -155404,7 +156006,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -155425,20 +156027,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -155499,7 +156101,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -155510,8 +156112,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -155560,7 +156162,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -155584,10 +156186,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -155604,7 +156206,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -155621,22 +156223,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -155671,7 +156273,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -155739,15 +156341,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -155762,11 +156364,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -155928,7 +156530,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -156029,9 +156631,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -156039,7 +156641,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -156082,7 +156684,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -156118,7 +156720,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -156126,9 +156728,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -156137,7 +156739,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -156151,7 +156753,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -156169,19 +156771,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -156323,24 +156925,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -156348,20 +156950,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -156385,13 +156987,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -156401,65 +157003,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -156467,31 +157069,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -156511,7 +157113,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -156536,7 +157138,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -156583,21 +157185,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -156616,22 +157218,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -156663,7 +157265,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -156680,7 +157282,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -156708,7 +157310,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -156722,7 +157324,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -156741,10 +157343,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -156758,8 +157360,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -156795,10 +157397,10 @@ var ts; var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); var _loop_16 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; @@ -156806,15 +157408,15 @@ var ts; _loop_16(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -156898,7 +157500,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -156965,7 +157567,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -156978,13 +157580,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -156994,11 +157596,11 @@ var ts; } } addClassElement(ts.factory.createPropertyDeclaration( - /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -157027,8 +157629,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -157036,7 +157638,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!ts.some(signatures)) { break; } @@ -157058,13 +157660,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -157074,11 +157676,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 1073741824 /* NoUndefinedOptionalParameterType */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -157131,7 +157732,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -157163,26 +157764,26 @@ var ts; ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; var typeParameters = isJs || typeArguments === undefined ? undefined : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); + return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* CharacterCodes.T */ + typeArguments.length - 1 <= 90 /* CharacterCodes.Z */ ? String.fromCharCode(84 /* CharacterCodes.T */ + i) : "T".concat(i)); }); var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, /*questionToken*/ undefined, typeParameters, parameters, type); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: @@ -157210,9 +157811,9 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ names && names[i] || "arg".concat(i), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -157242,8 +157843,8 @@ var ts; if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -157259,7 +157860,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -157268,16 +157869,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -157350,7 +157951,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -157423,17 +158024,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -157442,7 +158043,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -157460,13 +158061,13 @@ var ts; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -157522,13 +158123,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -157543,7 +158144,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -157555,7 +158156,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -157602,7 +158203,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -157720,7 +158321,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -157728,7 +158329,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -157757,7 +158358,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -157766,7 +158367,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -157774,7 +158375,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -157950,8 +158551,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -158014,7 +158615,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -158080,7 +158681,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -158138,7 +158739,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -158149,7 +158750,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -158221,7 +158822,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -158258,14 +158859,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -158278,6 +158879,7 @@ var ts; var fixName = "addVoidToPromise"; var fixId = "addVoidToPromise"; var errorCodes = [ + ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code, ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code ]; codefix.registerCodeFix({ @@ -158312,7 +158914,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -158324,14 +158926,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -158407,15 +159009,15 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var checker = program.getTypeChecker(); @@ -158424,22 +159026,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -158449,7 +159051,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -158473,18 +159075,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -158493,15 +159095,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -158522,18 +159124,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -158542,10 +159144,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -158556,7 +159158,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -158567,11 +159169,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -158584,7 +159186,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -158593,7 +159195,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -158612,17 +159214,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -158674,13 +159276,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -158688,11 +159290,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -158705,7 +159307,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -158754,14 +159356,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -158910,7 +159512,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -158926,7 +159528,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -159052,17 +159654,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -159077,7 +159679,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -159123,27 +159725,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -159165,24 +159767,24 @@ var ts; return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -159195,12 +159797,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -159326,7 +159928,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -159334,7 +159936,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -159350,7 +159952,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -159358,7 +159960,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -159454,6 +160056,7 @@ var ts; Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block"); + Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method"); })(Messages = extractSymbol.Messages || (extractSymbol.Messages = {})); var RangeFacts; (function (RangeFacts) { @@ -159462,10 +160065,11 @@ var ts; RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction"; /** * The range is in a function which needs the 'static' modifier in a class */ - RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion"; })(RangeFacts || (RangeFacts = {})); /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array @@ -159496,11 +160100,12 @@ var ts; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. var rangeFacts = RangeFacts.None; + var thisNode; if (!start || !end) { // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -159534,7 +160139,7 @@ var ts; // the expression. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. @@ -159546,7 +160151,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -159589,20 +160194,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -159626,7 +160231,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -159635,9 +160240,17 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); + if (rangeFacts & RangeFacts.UsesThis) { + var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { + rangeFacts |= RangeFacts.UsesThisInFunction; + } + } return errors; function visit(node) { if (errors) { @@ -159645,8 +160258,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -159657,16 +160270,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -159676,13 +160289,15 @@ var ts; } else { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) { return false; @@ -159692,63 +160307,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps = 0 /* PermittedJumps.None */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; + thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -159757,21 +160373,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -159794,7 +160410,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -159826,7 +160442,7 @@ var ts; */ function collectEnclosingScopes(range) { var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range; - if (range.facts & RangeFacts.UsesThis) { + if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class var containingClass = ts.getContainingClass(current); if (containingClass) { @@ -159840,7 +160456,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -159851,7 +160467,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -159891,11 +160507,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -159941,34 +160557,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -159999,7 +160615,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -160008,7 +160624,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -160027,27 +160643,37 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); var newFunction; + var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { + if (callThis) { + parameters.unshift(ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ "this", + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), + /*initializer*/ undefined)); + } newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -160062,10 +160688,13 @@ var ts; var newNodes = []; // replace range with function call var called = getCalledExpression(scope, range, functionNameText); - var call = ts.factory.createCallExpression(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference + if (callThis) { + callArguments.unshift(ts.factory.createIdentifier("this")); + } + var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -160099,7 +160728,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -160110,7 +160739,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -160125,8 +160754,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -160135,7 +160764,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -160192,9 +160821,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -160207,13 +160836,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -160221,11 +160850,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -160257,16 +160886,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -160276,7 +160905,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -160303,7 +160932,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -160322,7 +160951,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -160332,7 +160961,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -160345,10 +160974,10 @@ var ts; /* decorators */ undefined, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -160595,7 +161224,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -160673,14 +161302,17 @@ var ts; var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes)); } + if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) { + functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod)); + } var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -160724,7 +161356,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -160734,11 +161366,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -160812,7 +161444,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -160839,7 +161471,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -160920,30 +161552,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -161089,7 +161721,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -161120,7 +161752,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -161132,7 +161764,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -161158,7 +161790,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -161342,11 +161974,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -161386,7 +162018,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -161442,25 +162074,25 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -161478,21 +162110,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -161518,7 +162150,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -161542,7 +162174,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -161562,19 +162194,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -161583,7 +162215,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -161595,7 +162227,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -161608,14 +162240,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -161657,7 +162289,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -161674,7 +162306,7 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } function getNewModuleName(movedSymbols) { @@ -161684,7 +162316,7 @@ var ts; var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -161718,7 +162350,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -161736,7 +162368,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -161745,14 +162377,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -161764,7 +162396,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -161774,18 +162406,18 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -161795,11 +162427,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -161856,13 +162488,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -161870,19 +162502,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -161890,13 +162522,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -161904,9 +162536,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -161928,7 +162560,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -161936,28 +162568,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], d.modifiers); switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -161965,26 +162597,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -162047,14 +162679,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -162188,7 +162820,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -162287,7 +162919,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -162317,15 +162949,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -162335,7 +162967,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -162354,14 +162986,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -162373,7 +163005,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -162407,16 +163039,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -162424,8 +163056,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -162435,7 +163067,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -162541,7 +163173,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -162550,7 +163182,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -162575,15 +163207,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -162594,30 +163226,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -162698,16 +163330,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -162725,7 +163357,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -162738,7 +163370,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -162747,7 +163379,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -162839,8 +163471,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -163035,7 +163667,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -163061,7 +163693,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -163121,13 +163753,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -163137,7 +163769,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -163148,17 +163780,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -163185,20 +163817,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -163260,8 +163892,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -163272,7 +163904,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -163320,19 +163952,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -163349,9 +163981,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -163391,7 +164023,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -163443,12 +164075,12 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -163465,12 +164097,12 @@ var ts; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -163494,7 +164126,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -163506,7 +164138,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -163521,7 +164153,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -163543,16 +164175,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -163573,41 +164205,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -163671,7 +164303,7 @@ var ts; var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -163698,7 +164330,7 @@ var ts; var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -163719,7 +164351,7 @@ var ts; var _a; if (ts.hasStaticModifier(declaration)) return; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) { @@ -163731,7 +164363,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -163790,10 +164422,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -163813,31 +164445,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -163848,12 +164480,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -163866,7 +164498,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -163878,7 +164510,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -163887,8 +164519,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -163957,8 +164589,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -163977,7 +164609,7 @@ var ts; this.fileNameToEntry = new ts.Map(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "initializeHostCache", { count: rootFileNames.length }); for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); @@ -164047,7 +164679,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -164144,7 +164776,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -164174,7 +164806,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -164264,7 +164896,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -164384,7 +165016,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -164574,8 +165206,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -164608,27 +165240,27 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; } } /// Goto definition - function getDefinitionAtPosition(fileName, position) { + function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly, stopAtAlias) { synchronizeHostData(); - return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); + return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias); } function getDefinitionAndBoundSpan(fileName, position) { synchronizeHostData(); @@ -164645,7 +165277,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -164669,17 +165301,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -164726,16 +165358,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -164751,7 +165383,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -164781,8 +165413,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -164791,8 +165423,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -164813,10 +165445,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -164913,7 +165545,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -164922,15 +165554,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -164940,12 +165572,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -165042,14 +165674,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -165059,7 +165691,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -165145,10 +165777,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -165163,12 +165795,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -165286,9 +165918,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -165444,14 +166076,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -165498,7 +166130,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -165513,16 +166145,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -165564,7 +166196,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -165611,7 +166243,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -165644,144 +166276,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.decorators); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -165793,14 +166425,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -165809,35 +166441,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -165846,21 +166478,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -165868,7 +166500,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -165898,7 +166530,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -165909,8 +166541,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if (variableDeclaration.initializer || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -165925,7 +166557,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -165950,8 +166582,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -165974,26 +166606,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -166018,21 +166650,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -166040,18 +166672,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -166059,25 +166691,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -166085,7 +166717,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -166101,7 +166733,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -166116,12 +166748,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -166130,21 +166762,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -166154,20 +166786,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -166175,7 +166807,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -166343,7 +166975,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -166433,13 +167065,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -166521,7 +167153,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -166537,43 +167169,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -166589,7 +167221,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -166598,7 +167230,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -166606,12 +167238,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -166620,7 +167252,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -166628,7 +167260,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -166637,7 +167269,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -166646,37 +167278,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, options); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -166684,23 +167316,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -166715,108 +167347,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -166866,11 +167498,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -166881,7 +167513,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -166893,7 +167525,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -166908,7 +167540,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -166930,7 +167562,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -167713,11 +168345,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -167764,7 +168396,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -167801,7 +168433,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -167942,9 +168574,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -167971,7 +168603,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 297d2168c328e..75f7eaab2308a 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2172,7 +2172,9 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export interface WriteFileCallbackData { + } + export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -2394,7 +2396,6 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, - NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2892,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2901,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3073,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4817,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6434,7 +6435,18 @@ declare namespace ts { argumentIndex: number; argumentCount: number; } + enum CompletionInfoFlags { + None = 0, + MayIncludeAutoImports = 1, + IsImportStatementCompletion = 2, + IsContinuation = 4, + ResolvedModuleSpecifiers = 8, + ResolvedModuleSpecifiersBeyondLimit = 16, + MayIncludeMethodSnippets = 32 + } interface CompletionInfo { + /** For performance telemetry. */ + flags?: CompletionInfoFlags; /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; @@ -6810,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6829,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 19cfc7498466e..47396de3ee8dc 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -21,7 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -294,7 +294,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "".concat(ts.versionMajorMinor, ".1-rc"); /* @internal */ var Comparison; (function (Comparison) { @@ -341,7 +341,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -1033,9 +1033,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -1071,7 +1071,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -1125,27 +1125,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1385,12 +1385,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1844,7 +1844,7 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ @@ -1935,7 +1935,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -2007,11 +2007,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -2029,7 +2029,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -2046,14 +2046,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -2084,13 +2084,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -2120,7 +2120,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2181,9 +2181,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2302,24 +2302,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2329,7 +2329,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2385,7 +2385,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2485,12 +2485,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2621,7 +2621,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2700,7 +2700,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2708,12 +2708,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2723,26 +2723,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2773,42 +2773,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2829,7 +2829,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2850,7 +2850,7 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "" + result + (result ? "|" : "") + enumName; + result = "".concat(result).concat(result ? "|" : "").concat(enumName); remainingFlags &= ~enumValue; } } @@ -2947,20 +2947,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2999,7 +2999,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -3051,10 +3051,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -3063,35 +3063,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -3123,11 +3123,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -3159,7 +3159,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3206,10 +3206,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3323,9 +3323,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3340,11 +3340,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3373,11 +3373,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3394,7 +3394,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3611,7 +3611,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3909,7 +3909,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3921,11 +3921,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -4015,20 +4015,20 @@ var ts; } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -4064,7 +4064,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -4073,7 +4073,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -4081,7 +4081,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -4090,7 +4090,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -4100,7 +4100,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -4108,7 +4108,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -4117,7 +4117,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -4135,7 +4135,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4854,7 +4854,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; - NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -5471,10 +5470,11 @@ var ts; ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16"; ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var ModuleDetectionKind; @@ -5484,7 +5484,7 @@ var ts; */ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy"; /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto"; /** @@ -5529,8 +5529,8 @@ var ts; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + ModuleKind[ModuleKind["Node16"] = 100] = "Node16"; ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); var JsxEmit; @@ -6066,37 +6066,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6168,7 +6168,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6385,7 +6385,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6637,7 +6637,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6650,7 +6650,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6666,7 +6666,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6689,7 +6689,7 @@ var ts; var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6784,7 +6784,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6839,7 +6839,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6871,7 +6871,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -7126,7 +7126,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7135,7 +7135,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7151,7 +7151,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7253,7 +7253,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -7278,7 +7278,7 @@ var ts; } } if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -7294,7 +7294,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7445,8 +7445,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7458,10 +7458,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7525,8 +7525,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7549,7 +7549,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7636,16 +7636,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7659,18 +7659,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7690,7 +7690,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7767,7 +7767,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -8051,17 +8051,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -8078,7 +8078,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8452,6 +8452,7 @@ var ts; _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), @@ -8463,10 +8464,10 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), - Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -8481,7 +8482,7 @@ var ts; 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_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_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -8512,7 +8513,7 @@ var ts; await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -8564,7 +8565,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), - Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), @@ -8582,7 +8583,7 @@ var ts; Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), - Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."), + Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."), resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), @@ -8593,7 +8594,7 @@ var ts; An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), - auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8602,7 +8603,8 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), - This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -8853,7 +8855,6 @@ var ts; A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), - 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."), Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), 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."), @@ -8911,6 +8912,7 @@ var ts; _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -9066,6 +9068,7 @@ var ts; This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), @@ -9079,8 +9082,8 @@ var ts; Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), @@ -9191,6 +9194,7 @@ var ts; This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -9746,7 +9750,6 @@ var ts; This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), - JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -10056,100 +10059,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10238,16 +10241,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10276,17 +10279,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10311,7 +10314,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10389,18 +10392,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10414,50 +10417,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10471,29 +10474,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10504,10 +10507,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10517,24 +10520,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10542,7 +10545,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10566,8 +10569,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10578,18 +10581,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10650,12 +10653,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10665,20 +10668,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10689,7 +10692,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10714,7 +10717,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10769,17 +10772,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10798,7 +10801,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10821,15 +10824,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10884,8 +10887,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10909,7 +10912,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10919,15 +10922,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10940,7 +10943,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10952,10 +10955,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -11013,8 +11016,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11029,11 +11032,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -11043,7 +11046,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -11057,7 +11060,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11067,7 +11070,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -11075,7 +11078,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11088,7 +11091,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -11096,28 +11099,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11125,10 +11128,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11151,47 +11154,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11199,29 +11202,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11229,14 +11232,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11269,7 +11272,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11285,7 +11288,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11295,7 +11298,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11313,11 +11316,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11326,7 +11329,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11345,14 +11348,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11363,8 +11366,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11379,101 +11382,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11482,98 +11485,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11586,20 +11589,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11607,7 +11610,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11619,18 +11622,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11638,10 +11641,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11649,10 +11652,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11660,175 +11663,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11838,7 +11841,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11849,23 +11852,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11879,41 +11882,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11921,13 +11924,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11936,19 +11939,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11958,7 +11961,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11979,9 +11982,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11989,7 +11992,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -12003,42 +12006,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -12046,20 +12049,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -12082,7 +12085,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -12095,16 +12098,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12125,10 +12128,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12140,86 +12143,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12294,9 +12297,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12362,23 +12365,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12586,9 +12589,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12596,7 +12599,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12626,14 +12629,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12747,7 +12750,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12765,7 +12768,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12776,7 +12779,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12806,30 +12809,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12864,42 +12867,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -13192,16 +13195,16 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a @@ -13212,7 +13215,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13239,33 +13242,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13300,7 +13303,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13309,25 +13312,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13336,12 +13339,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13357,7 +13360,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13366,7 +13369,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13387,7 +13390,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13397,7 +13400,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13406,8 +13409,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13416,13 +13419,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13434,13 +13437,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13458,20 +13461,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13479,12 +13482,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13493,24 +13496,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13530,18 +13533,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13550,14 +13553,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13572,30 +13575,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13605,13 +13608,13 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13620,12 +13623,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13640,8 +13643,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13652,8 +13655,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13661,15 +13664,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13678,9 +13681,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13701,8 +13704,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13711,10 +13714,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13726,8 +13729,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13736,26 +13739,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13763,13 +13766,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13779,36 +13782,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13821,13 +13824,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13836,11 +13839,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13857,15 +13860,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13873,8 +13876,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13885,13 +13888,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13909,18 +13912,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13944,115 +13947,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14079,10 +14082,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14096,76 +14099,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14175,15 +14178,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14209,13 +14212,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14223,12 +14226,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14257,11 +14260,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion @@ -14302,7 +14305,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14463,11 +14466,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14498,28 +14501,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14530,16 +14533,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14554,7 +14557,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14607,7 +14610,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14641,7 +14644,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14673,9 +14676,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14687,13 +14690,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14702,7 +14705,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14710,10 +14713,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14724,7 +14727,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14735,7 +14738,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14896,62 +14899,62 @@ var ts; var _a; // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14966,21 +14969,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -15004,16 +15007,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -15025,9 +15028,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -15039,7 +15042,7 @@ var ts; } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isCommonJSContainingModuleKind(kind) { - return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext; } function isEffectiveExternalModule(node, compilerOptions) { return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); @@ -15051,10 +15054,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15084,24 +15087,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15111,9 +15114,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15123,25 +15126,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15151,25 +15154,29 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; } } ts.isAnyImportSyntax = isAnyImportSyntax; + function isAnyImportOrBareOrAccessedRequire(node) { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15210,19 +15217,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15237,21 +15244,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15341,7 +15348,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15355,7 +15362,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15364,29 +15371,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15418,36 +15425,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15456,12 +15463,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15480,24 +15487,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15506,48 +15513,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15556,40 +15563,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15614,23 +15621,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15640,23 +15647,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15679,10 +15686,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15692,12 +15699,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15705,14 +15712,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15724,21 +15731,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15749,13 +15756,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15766,7 +15773,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15774,30 +15781,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15859,14 +15866,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15881,9 +15888,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15894,27 +15901,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15927,17 +15934,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15961,9 +15968,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15985,28 +15992,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16022,21 +16029,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -16045,8 +16052,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -16054,34 +16061,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16089,10 +16096,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16105,25 +16112,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16139,11 +16146,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16159,9 +16166,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16169,64 +16176,64 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16236,49 +16243,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16286,10 +16293,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16297,7 +16304,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16310,7 +16317,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16322,11 +16329,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16334,7 +16341,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16342,15 +16349,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16376,7 +16383,7 @@ var ts; } ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { - if (node.kind === 203 /* BindingElement */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && @@ -16390,11 +16397,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16405,7 +16412,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16432,7 +16439,7 @@ var ts; * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16458,11 +16465,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16480,7 +16487,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16488,7 +16495,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16496,8 +16503,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16519,17 +16526,13 @@ var ts; if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - var nameOrArgument = getNameOrArgument(initializer); - if (ts.isPrivateIdentifier(nameOrArgument)) { - ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -16563,7 +16566,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16588,14 +16591,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16614,23 +16617,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16667,17 +16670,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16689,14 +16692,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16707,12 +16710,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16720,7 +16723,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16733,18 +16736,18 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { - var _a, _b, _c; + var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: - return node.initializer.arguments[0].text; - case 266 /* ImportDeclaration */: - return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: - return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + case 254 /* SyntaxKind.VariableDeclaration */: + return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; + case 266 /* SyntaxKind.ImportDeclaration */: + return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); } @@ -16756,14 +16759,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16773,17 +16776,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16791,11 +16794,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16803,7 +16806,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16824,13 +16827,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16844,7 +16847,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16854,27 +16857,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16886,7 +16889,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16901,11 +16904,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16934,13 +16937,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16951,7 +16954,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16975,7 +16978,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -17041,7 +17044,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -17058,41 +17061,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17103,7 +17106,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17112,22 +17115,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17144,11 +17147,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17158,7 +17161,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17167,18 +17170,18 @@ var ts; ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17199,13 +17202,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17216,13 +17219,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17231,7 +17234,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17239,27 +17242,30 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - // Any name in an export specifier or JSX Attribute + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + // Any name in an export specifier or JSX Attribute or Jsx Element return true; } return false; @@ -17275,36 +17281,44 @@ var ts; // export = // export default // module.exports = - // {} - // {name: } + // module.exports.x = + // const x = require("...") + // const { x } = require("...") + // const x = require("...").y + // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 297 /* ShorthandPropertyAssignment */ || - node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { + return true; + } + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) + && ts.isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17323,7 +17337,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17340,7 +17354,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17349,7 +17363,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17362,7 +17376,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17389,11 +17403,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17401,7 +17415,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17420,7 +17434,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17433,38 +17447,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17474,7 +17488,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17491,7 +17505,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17501,19 +17515,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17526,10 +17540,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17545,11 +17559,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17564,7 +17578,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17573,11 +17587,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17585,15 +17599,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17612,58 +17626,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17842,129 +17856,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17974,9 +17988,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18091,9 +18105,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18108,8 +18122,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18139,13 +18153,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18164,13 +18178,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18187,6 +18201,10 @@ var ts; return indentStrings[1].length; } ts.getIndentSize = getIndentSize; + function isNightly() { + return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders"); + } + ts.isNightly = isNightly; function createTextWriter(newLine) { var output; var indent; @@ -18411,12 +18429,22 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; + /** + * This function is an inverse of `getDeclarationEmitExtensionForPath`. + */ + function getPossibleOriginalInputExtensionForExtension(path) { + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; + } + ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { return options.outFile || options.out; } @@ -18476,10 +18504,10 @@ var ts; return ts.combinePaths(newDirPath, sourceFilePath); } ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) { diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } ts.writeFile = writeFile; function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) { @@ -18542,7 +18570,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18552,11 +18580,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18567,10 +18595,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18590,10 +18618,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18642,7 +18670,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18759,7 +18787,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18834,7 +18862,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18846,11 +18874,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18867,23 +18895,23 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18895,16 +18923,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18929,22 +18957,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18964,14 +18992,14 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18983,22 +19011,22 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -19006,15 +19034,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -19022,7 +19050,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19035,14 +19063,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19054,8 +19082,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19065,33 +19093,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19122,10 +19150,15 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfAccessExpression(node) { + return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { return ts.isQualifiedName(node.parent) && node.parent.right === node || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -19133,12 +19166,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19154,7 +19187,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19325,9 +19358,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19470,8 +19503,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19495,32 +19528,32 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SyntaxKind.SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19529,11 +19562,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19548,47 +19581,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19658,9 +19691,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19671,11 +19704,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19722,44 +19755,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19767,7 +19800,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19777,31 +19810,66 @@ var ts; return expr; } ts.getLeftmostAccessExpression = getLeftmostAccessExpression; + function forEachNameInAccessChainWalkingLeft(name, action) { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + function walkAccessExpression(access) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { + if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { + var res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + // Chain interrupted by non-static-name access 'x[expr()].y.z' + return undefined; + } + } + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (ts.isIdentifier(access.expression)) { + // End of chain at Identifier 'x.y.z' + return action(access.expression); + } + // End of chain at non-Identifier 'x().y.z' + return undefined; + } + } + ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19835,9 +19903,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19846,8 +19914,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19855,8 +19923,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20051,7 +20119,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20060,43 +20128,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20106,16 +20174,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20124,7 +20192,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20156,15 +20224,15 @@ var ts; file.externalModuleIndicator = ts.isFileProbablyExternalModule(file); }; case ts.ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } var combined_1 = ts.or.apply(void 0, checks); @@ -20175,15 +20243,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20193,8 +20261,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -20219,7 +20287,7 @@ var ts; case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; default: @@ -20244,7 +20312,7 @@ var ts; return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; } @@ -20280,7 +20348,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20297,14 +20365,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20312,13 +20380,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20417,9 +20485,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20432,7 +20500,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20441,7 +20509,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20459,10 +20527,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20484,7 +20552,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20521,11 +20589,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20562,7 +20630,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20687,43 +20755,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20731,7 +20800,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20742,11 +20811,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20777,7 +20846,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20830,11 +20899,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20843,7 +20912,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20952,23 +21021,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20984,10 +21053,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21022,7 +21091,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21033,34 +21102,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21201,7 +21270,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21221,18 +21290,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return node.parent.decorators; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21240,45 +21309,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21290,7 +21359,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21308,7 +21377,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21317,7 +21386,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21356,7 +21425,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21376,42 +21445,47 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; + function getParameterTypeNode(parameter) { + var _a; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + } + ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); /* @internal */ var ts; @@ -21534,28 +21608,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21566,7 +21640,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21586,8 +21660,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21603,7 +21677,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21621,10 +21695,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21637,7 +21711,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21645,11 +21719,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21663,7 +21737,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21680,10 +21754,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21713,8 +21787,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21727,9 +21801,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21749,7 +21823,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21771,7 +21845,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21780,21 +21854,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21812,16 +21886,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21833,8 +21907,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21849,8 +21923,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21867,14 +21941,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21894,9 +21968,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22090,11 +22164,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22152,10 +22226,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22286,12 +22360,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22447,18 +22521,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22494,30 +22568,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22585,38 +22659,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22720,11 +22794,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22742,7 +22816,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) { @@ -22753,7 +22827,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseSignatureDeclaration(updated, original) { @@ -22765,9 +22839,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseFunctionLikeDeclaration(updated, original) { @@ -22801,7 +22875,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22814,21 +22888,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22837,7 +22911,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22848,19 +22922,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22870,10 +22944,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22892,8 +22966,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22905,9 +22979,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22917,25 +22991,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22943,9 +23017,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 8388608 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22955,51 +23029,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 33554432 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 8192 /* ContainsLexicalThis */; + transformFlags = 8192 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23012,23 +23086,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23040,34 +23114,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23075,7 +23149,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23092,12 +23166,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 65536 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23120,11 +23194,11 @@ var ts; name = modifiersOrName; constraint = nameOrConstraint; } - var node = createBaseNamedDeclaration(163 /* TypeParameter */, + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, /*decorators*/ undefined, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateTypeParameterDeclaration(node, modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { @@ -23150,22 +23224,22 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23183,12 +23257,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + 1 /* TransformFlags.ContainsTypeScript */ | + 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; return node; } // @api @@ -23202,11 +23276,11 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23220,18 +23294,18 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + 8388608 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23249,10 +23323,10 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23268,26 +23342,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -23307,11 +23381,11 @@ var ts; } // @api function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, decorators, modifiers, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @api @@ -23324,11 +23398,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23342,7 +23416,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(172 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -23358,7 +23432,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(173 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -23374,11 +23448,11 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23391,11 +23465,11 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23408,10 +23482,10 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23425,10 +23499,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23447,11 +23521,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23464,10 +23538,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23479,11 +23553,11 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23505,10 +23579,10 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23539,10 +23613,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23554,9 +23628,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23567,9 +23641,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23580,9 +23654,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23593,12 +23667,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23612,9 +23686,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23625,9 +23699,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23639,7 +23713,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23649,7 +23723,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23657,7 +23731,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23665,12 +23739,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23684,9 +23758,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23697,10 +23771,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23711,22 +23785,22 @@ var ts; : node; } function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertion; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; @@ -23741,9 +23815,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23754,18 +23828,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23776,10 +23850,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23791,14 +23865,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23814,9 +23888,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23830,16 +23904,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23851,12 +23925,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23867,21 +23941,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 16384 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23903,7 +23977,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23922,7 +23996,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23936,7 +24010,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -23948,8 +24022,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23965,13 +24039,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -23981,7 +24055,7 @@ var ts; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -23992,7 +24066,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -24002,8 +24076,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24019,8 +24093,8 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); @@ -24028,12 +24102,12 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24044,7 +24118,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24053,13 +24127,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 4194304 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24076,8 +24150,8 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); @@ -24087,18 +24161,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24108,7 +24182,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24116,9 +24190,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24132,7 +24206,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -24140,12 +24214,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24159,13 +24233,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24177,7 +24251,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24190,23 +24264,23 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24224,15 +24298,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24249,7 +24323,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24262,7 +24336,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24275,7 +24349,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24288,13 +24362,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24305,17 +24379,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24327,7 +24401,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24336,7 +24410,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24348,7 +24422,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24358,46 +24432,46 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) - return 32768 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return 32768 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24405,7 +24479,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24417,11 +24491,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24443,13 +24517,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24460,8 +24534,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24487,41 +24561,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 524288 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24533,12 +24607,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24549,8 +24623,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24566,17 +24640,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24588,13 +24662,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24606,11 +24680,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24624,33 +24698,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24668,13 +24742,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24686,8 +24760,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24695,7 +24769,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24709,12 +24783,12 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24727,11 +24801,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24744,7 +24818,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24764,7 +24838,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24781,7 +24855,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24798,7 +24872,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24821,7 +24895,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24841,7 +24915,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24851,9 +24925,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24867,11 +24941,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24882,11 +24956,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24897,13 +24971,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24914,7 +24988,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24931,7 +25005,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24948,7 +25022,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24965,7 +25039,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24978,7 +25052,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -24998,17 +25072,17 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25023,17 +25097,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25045,25 +25119,25 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } return node; @@ -25083,14 +25157,14 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25108,9 +25182,9 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25126,9 +25200,9 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25143,12 +25217,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -25162,21 +25236,21 @@ var ts; } // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */, decorators, modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */, decorators, modifiers); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -25190,7 +25264,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25203,7 +25277,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25216,10 +25290,10 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25230,13 +25304,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -25251,14 +25325,14 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25273,7 +25347,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25281,9 +25355,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25296,10 +25370,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25311,10 +25385,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25326,7 +25400,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25340,10 +25414,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25354,12 +25428,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25370,10 +25444,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25384,14 +25458,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25404,13 +25478,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25423,7 +25497,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -25431,7 +25505,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25447,10 +25521,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25461,14 +25535,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25481,7 +25555,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */, + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -25491,10 +25565,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25549,7 +25623,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -25566,7 +25640,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25580,7 +25654,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25592,7 +25666,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25621,7 +25695,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25638,7 +25712,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25656,7 +25730,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25677,7 +25751,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25698,7 +25772,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25716,7 +25790,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25731,13 +25805,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25751,7 +25825,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25763,7 +25837,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25780,7 +25854,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25793,7 +25867,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25806,7 +25880,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25878,7 +25952,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -25890,7 +25964,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -25902,7 +25976,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -25919,7 +25993,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -25927,7 +26001,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25940,7 +26014,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25948,9 +26022,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25964,7 +26038,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25972,9 +26046,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25988,11 +26062,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26003,7 +26077,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26011,7 +26085,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26024,10 +26098,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26039,25 +26113,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26069,11 +26143,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26084,11 +26158,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26099,13 +26173,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26119,7 +26193,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26136,7 +26210,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26149,16 +26223,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26173,7 +26247,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26186,7 +26260,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26201,7 +26275,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -26231,13 +26305,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -26263,12 +26337,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26282,13 +26356,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26303,7 +26377,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26320,7 +26394,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26359,7 +26433,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26374,7 +26448,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26392,28 +26466,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26424,7 +26498,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26432,7 +26506,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26447,7 +26521,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26461,12 +26535,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26489,7 +26563,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26506,7 +26580,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26517,14 +26591,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26546,12 +26620,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26665,11 +26739,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26695,7 +26769,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26716,20 +26790,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26737,7 +26811,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26746,11 +26820,11 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); } @@ -26817,9 +26891,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26838,7 +26912,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26851,7 +26925,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26864,7 +26938,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -26889,9 +26963,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -26908,7 +26982,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -26966,7 +27040,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27155,52 +27229,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27209,14 +27283,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27225,22 +27299,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 33562624 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27252,78 +27326,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 589443072 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 557748224 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 591310848 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537165824 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 536940544 /* ClassExcludes */; - case 171 /* Constructor */: - return 591306752 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 570433536 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 574529536 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 536973312 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536903680 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536887296 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return 536887296 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return 589443072 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return 536870912 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return 557748224 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return 591310848 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return 537165824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return 536940544 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return 591306752 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return 570433536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return 574529536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return 536973312 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return 536903680 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return 536887296 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return 536870912 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return 536870912 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return 536870912 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27333,7 +27407,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27396,50 +27470,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27467,22 +27541,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27510,7 +27584,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27579,7 +27653,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27621,7 +27695,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27630,7 +27704,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27662,7 +27736,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -27898,7 +27972,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -27921,8 +27995,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -27963,7 +28037,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -27998,7 +28072,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28014,7 +28088,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28068,13 +28142,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28087,7 +28161,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28177,13 +28251,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28590,7 +28664,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28599,741 +28673,741 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29341,176 +29415,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29530,7 +29604,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29709,14 +29783,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29755,7 +29829,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29780,14 +29854,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29795,7 +29869,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29824,8 +29898,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29841,26 +29915,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29868,7 +29942,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -29930,7 +30004,7 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -29975,10 +30049,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30097,7 +30171,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30109,11 +30183,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30145,12 +30219,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30168,7 +30242,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30183,7 +30257,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30198,7 +30272,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30213,21 +30287,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30248,29 +30322,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30281,68 +30355,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30350,21 +30424,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30497,7 +30571,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30578,7 +30652,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30598,9 +30672,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30612,14 +30686,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 93 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30631,7 +30705,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30647,20 +30721,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30668,9 +30742,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -30678,7 +30752,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30686,51 +30760,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.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 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30742,345 +30816,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.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 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31089,64 +31163,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31195,7 +31269,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31220,13 +31294,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31274,7 +31348,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31302,8 +31376,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31325,7 +31399,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31423,7 +31497,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31442,25 +31516,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31468,28 +31542,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31507,7 +31581,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31516,10 +31590,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31556,15 +31630,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31596,13 +31670,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31635,7 +31709,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31663,12 +31737,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31686,7 +31760,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31706,8 +31780,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31748,7 +31822,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -31775,16 +31849,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -31825,52 +31899,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -31971,15 +32045,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -31991,7 +32065,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -31999,31 +32073,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32061,7 +32135,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32076,17 +32150,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32096,7 +32170,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32121,24 +32195,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32149,7 +32223,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32216,24 +32290,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32250,7 +32324,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32262,11 +32336,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32290,23 +32364,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32319,23 +32393,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32348,12 +32422,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32381,23 +32455,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32405,9 +32479,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32418,18 +32492,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32438,50 +32512,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32493,42 +32567,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32537,7 +32611,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32554,8 +32628,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32570,51 +32644,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32634,7 +32708,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32642,7 +32716,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32708,7 +32782,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32731,38 +32805,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -32809,20 +32883,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -32831,8 +32905,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -32841,58 +32915,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -32913,7 +32987,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -32931,39 +33005,39 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` } } @@ -32978,11 +33052,12 @@ var ts; var startPos = scanner.getStartPos(); var result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -32992,13 +33067,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33027,7 +33102,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33045,18 +33120,18 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) { + function parseEntityName(allowReservedWords, diagnosticMessage) { var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; } dotPos = getNodePos(); - entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos); + entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos); } return entity; } @@ -33089,12 +33164,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33105,7 +33180,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33123,7 +33198,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33131,13 +33206,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33152,30 +33227,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33189,11 +33264,11 @@ var ts; } // TYPES function parseEntityNameOfTypeReference() { - return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected); + return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33203,14 +33278,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33248,12 +33323,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33265,8 +33340,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33274,9 +33349,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*decorators*/ undefined, @@ -33290,15 +33365,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33307,13 +33382,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33321,9 +33396,10 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true); - var typeArguments = tryParseTypeArguments(); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); + var entityName = parseEntityName(/*allowReservedWords*/ true); + // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. + var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } function parseTypeParameter() { @@ -33332,7 +33408,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33351,21 +33427,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33389,7 +33465,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33405,7 +33481,7 @@ var ts; // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), @@ -33419,11 +33495,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33433,16 +33509,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33464,11 +33540,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33487,17 +33563,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33506,20 +33582,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33539,7 +33615,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33558,21 +33634,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(decorators, modifiers, parameters, type); @@ -33580,14 +33656,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33596,7 +33672,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33604,10 +33680,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33617,7 +33693,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33628,30 +33704,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33660,16 +33736,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33680,9 +33756,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33691,51 +33767,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33748,10 +33824,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -33760,10 +33836,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33772,21 +33848,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33795,10 +33871,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -33808,34 +33884,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -33844,89 +33920,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -33934,48 +34010,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -33985,18 +34061,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34004,15 +34080,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34028,9 +34104,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34044,17 +34120,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34083,7 +34159,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34097,35 +34173,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34135,7 +34211,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34143,17 +34219,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34174,65 +34250,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34243,19 +34319,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34273,10 +34349,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34289,10 +34365,10 @@ var ts; setDecoratorContext(/*val*/ false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos); + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -34300,9 +34376,9 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) { + function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -34328,7 +34404,7 @@ var ts; // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -34342,12 +34418,12 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then @@ -34356,13 +34432,13 @@ var ts; // Note: we call reScanGreaterToken so that we get an appropriately merged token // for cases like `> > =` becoming `>>=` if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } // It wasn't an assignment or a lambda. This is a conditional expression: return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34398,8 +34474,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher()), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34407,8 +34483,8 @@ var ts; return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, disallowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -34418,14 +34494,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34433,53 +34509,53 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? - parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) : - tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); }); + return triState === 1 /* Tristate.True */ ? + parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } // True -> We definitely expect a parenthesized arrow function here. // False -> There *cannot* be a parenthesized arrow function here. // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34488,102 +34564,102 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - return 1 /* True */; + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function parsePossibleParenthesizedArrowFunctionExpression() { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction); + var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, asyncModifier); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); } } return undefined; @@ -34592,26 +34668,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity, disallowReturnTypeInArrowFunction) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34621,7 +34697,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34638,28 +34714,11 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - // Given: - // x ? y => ({ y }) : z => ({ z }) - // We try to parse the body of the first arrow function by looking at: - // ({ y }) : z => ({ z }) - // This is a valid arrow function with "z" as the return type. - // - // But, if we're in the true side of a conditional expression, this colon - // terminates the expression, so we cannot allow a return type if we aren't - // certain whether or not the preceding text was parsed as a parameter list. - // - // For example, - // a() ? (b: number, c?: string): void => d() : e - // is determined by isParenthesizedArrowFunctionExpression to unambiguously - // be an arrow expression, so we allow a return type. - if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) { - return undefined; - } - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34674,31 +34733,31 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) : parseIdentifier(); var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync, disallowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + function parseArrowFunctionExpressionBody(isAsync) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34715,28 +34774,28 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }) - : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } function parseConditionalExpressionRest(leftOperand, pos) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher() + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -34744,7 +34803,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -34773,16 +34832,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -34803,7 +34862,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -34831,7 +34890,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -34864,7 +34923,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -34881,10 +34940,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -34909,23 +34968,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -34948,18 +35007,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -34980,17 +35039,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35031,29 +35090,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35115,19 +35174,19 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35135,11 +35194,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35165,11 +35224,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35180,11 +35239,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35194,13 +35253,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35214,15 +35273,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35232,14 +35291,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35251,21 +35310,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35273,8 +35332,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35295,60 +35354,60 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : - scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* SyntaxKind.EqualsToken */ ? undefined : + scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35361,11 +35420,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35378,36 +35437,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35428,8 +35487,8 @@ var ts; } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35438,7 +35497,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35449,30 +35508,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35487,14 +35546,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35503,7 +35562,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35511,9 +35570,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35526,7 +35585,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35534,22 +35593,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(31 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35562,58 +35621,34 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` - // These tokens can't follow in a call expression, nor can they start an - // expression. So, consider the type argument list part of an instantiation - // expression. - // falls through - case 27 /* CommaToken */: // foo, - case 24 /* DotToken */: // foo. - case 28 /* QuestionDotToken */: // foo?. - case 21 /* CloseParenToken */: // foo) - case 23 /* CloseBracketToken */: // foo] - case 58 /* ColonToken */: // foo: - case 26 /* SemicolonToken */: // foo; - case 57 /* QuestionToken */: // foo? - case 34 /* EqualsEqualsToken */: // foo == - case 36 /* EqualsEqualsEqualsToken */: // foo === - case 35 /* ExclamationEqualsToken */: // foo != - case 37 /* ExclamationEqualsEqualsToken */: // foo !== - case 55 /* AmpersandAmpersandToken */: // foo && - case 56 /* BarBarToken */: // foo || - case 60 /* QuestionQuestionToken */: // foo ?? - case 52 /* CaretToken */: // foo ^ - case 50 /* AmpersandToken */: // foo & - case 51 /* BarToken */: // foo | - case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; } - // Treat anything else as an expression. - return false; + // Consider something a type argument list only if the following token can't start an expression. + return !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35621,21 +35656,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35643,21 +35678,21 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); + var expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -35665,34 +35700,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { + var expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35701,18 +35736,18 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); - var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }) : undefined; + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); + var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful. node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); - var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); + parseExpected(58 /* SyntaxKind.ColonToken */); + var initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker @@ -35725,10 +35760,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35742,17 +35777,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -35763,20 +35798,20 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -35784,13 +35819,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -35803,9 +35838,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -35814,7 +35849,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -35826,58 +35861,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -35885,26 +35920,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { - var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); - parseExpected(21 /* CloseParenToken */); + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { + var expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35912,10 +35947,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35923,7 +35958,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -35931,47 +35966,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -35980,7 +36015,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36000,25 +36035,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36030,7 +36065,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36041,9 +36076,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36064,25 +36099,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36105,44 +36140,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36155,51 +36190,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36209,7 +36244,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36218,68 +36253,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36288,7 +36323,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -36311,16 +36346,16 @@ var ts; if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { var node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -36329,33 +36364,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36364,7 +36399,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36375,10 +36410,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* SyntaxKind.OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -36387,26 +36422,26 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36414,29 +36449,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36449,8 +36484,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36462,13 +36497,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36484,19 +36519,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36509,27 +36544,27 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36540,9 +36575,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); // Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker. node.typeParameters = typeParameters; @@ -36552,11 +36587,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36564,20 +36599,20 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); @@ -36585,21 +36620,21 @@ var ts; function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 173 /* SetAccessor */) + if (type && node.kind === 173 /* SyntaxKind.SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36616,7 +36651,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36626,24 +36661,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36657,7 +36692,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); } @@ -36672,7 +36707,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36685,7 +36720,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36702,17 +36737,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -36733,7 +36768,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -36741,33 +36776,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -36779,17 +36814,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36797,21 +36832,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -36819,17 +36854,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36845,45 +36880,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -36892,11 +36927,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36913,12 +36948,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -36929,9 +36964,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -36941,10 +36976,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36952,17 +36987,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -36973,37 +37008,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37013,7 +37048,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37021,7 +37056,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37035,15 +37070,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37052,21 +37087,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); - var value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37080,15 +37115,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -37106,26 +37141,26 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37141,8 +37176,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37155,17 +37190,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37190,10 +37225,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37228,15 +37263,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37256,26 +37291,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37287,13 +37322,13 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -37337,11 +37372,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37353,10 +37388,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37365,16 +37400,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); - var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); - while (token() === 80 /* PrivateIdentifier */) { + var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37382,9 +37417,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37394,9 +37429,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37444,7 +37479,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37457,16 +37492,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37474,35 +37509,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37510,10 +37545,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37532,7 +37567,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37561,26 +37596,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37588,14 +37623,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37603,7 +37638,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37652,7 +37687,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37690,7 +37725,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37705,31 +37740,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -37741,8 +37776,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37756,32 +37791,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -37798,7 +37833,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -37810,17 +37845,17 @@ var ts; // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false) + ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -37831,8 +37866,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -37860,35 +37895,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -37904,12 +37939,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -37920,12 +37955,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -37946,8 +37981,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -37969,14 +38004,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -37995,21 +38030,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38043,7 +38078,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38060,7 +38095,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38084,11 +38119,11 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38100,7 +38135,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38111,9 +38146,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38122,7 +38157,8 @@ var ts; if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + var end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -38137,18 +38173,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38156,26 +38192,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38183,15 +38219,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38203,7 +38239,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38211,9 +38247,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38230,7 +38266,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38245,7 +38281,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38258,16 +38294,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38275,7 +38311,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38292,7 +38328,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38447,9 +38483,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38704,7 +38740,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -38719,7 +38755,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -38757,7 +38793,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -38810,7 +38846,7 @@ var ts; })(IncrementalParser || (IncrementalParser = {})); /** @internal */ function isDeclarationFileName(fileName) { - return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]); + return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions); } ts.isDeclarationFileName = isDeclarationFileName; function parseResolutionMode(mode, pos, end, reportDiagnostic) { @@ -38937,18 +38973,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -38982,15 +39018,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39033,10 +39069,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39056,11 +39092,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39131,6 +39167,7 @@ var ts; ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -39363,18 +39400,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39383,7 +39420,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; var commandOptionsWithoutBuild = [ // CommandLine only options @@ -39466,7 +39503,7 @@ var ts; es2020: ts.ModuleKind.ES2020, es2022: ts.ModuleKind.ES2022, esnext: ts.ModuleKind.ESNext, - node12: ts.ModuleKind.Node12, + node16: ts.ModuleKind.Node16, nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -39641,15 +39678,15 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -39820,7 +39857,7 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, - node12: ts.ModuleResolutionKind.Node12, + node16: ts.ModuleResolutionKind.Node16, nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -40063,8 +40100,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, @@ -40296,7 +40333,7 @@ var ts; affectsModuleResolution: true, description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: ts.Diagnostics.Language_and_Environment, - defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; /* @internal */ @@ -40417,7 +40454,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40442,8 +40479,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40502,11 +40539,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40535,14 +40572,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40553,7 +40590,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -40888,7 +40925,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -40928,7 +40965,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -40995,16 +41032,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41019,16 +41056,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41045,7 +41082,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41237,10 +41274,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41291,19 +41328,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41312,25 +41349,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41385,7 +41422,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -41730,8 +41767,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -41972,11 +42009,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42120,7 +42157,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42154,13 +42191,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42183,7 +42220,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42261,7 +42298,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42318,7 +42355,8 @@ var ts; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; - Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; + Extensions[Extensions["TsOnly"] = 5] = "TsOnly"; })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -42328,7 +42366,7 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { var _a; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -42336,7 +42374,8 @@ var ts; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations: failedLookupLocations + failedLookupLocations: failedLookupLocations, + resolutionDiagnostics: diagnostics }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -42413,7 +42452,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42476,7 +42515,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -42531,13 +42570,24 @@ var ts; // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions }; + var diagnostics = []; + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -42556,7 +42606,7 @@ var ts; isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); @@ -42622,7 +42672,7 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getDefaultNodeResolutionFeatures(options) { - return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -42639,6 +42689,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ts.emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: ts.noop }; return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { @@ -42681,7 +42733,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -42832,7 +42884,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -42867,7 +42919,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -42980,8 +43032,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -43001,8 +43053,8 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ts.ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ts.ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ts.ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43014,10 +43066,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43220,7 +43272,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43236,15 +43288,15 @@ var ts; // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; - NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default"; + NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default"; NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault"; NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); - function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { - return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); } function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43263,15 +43315,34 @@ var ts; return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + var extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) + extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) + extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). + var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + var diagnostics = []; var state = { compilerOptions: compilerOptions, host: host, @@ -43279,10 +43350,12 @@ var ts; failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -43342,7 +43415,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43409,7 +43482,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43428,7 +43501,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43445,7 +43518,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43455,9 +43528,9 @@ var ts; } } function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) { var result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; + return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } @@ -43473,53 +43546,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: + case Extensions.TsOnly: + var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43578,6 +43653,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features: features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: ts.noop }; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); @@ -43664,6 +43741,8 @@ var ts; packageJsonInfoCache: packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: ts.noop }; var parts = ts.getPathComponents(fileName); parts.pop(); @@ -43727,6 +43806,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -43799,14 +43879,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; + case Extensions.TsOnly: + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -43843,7 +43925,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -43952,7 +44034,6 @@ var ts; function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { return loadModuleFromTargetImportOrExport; function loadModuleFromTargetImportOrExport(target, subpath, pattern) { - var _a, _b; if (typeof target === "string") { if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { if (state.traceEnabled) { @@ -43989,13 +44070,16 @@ var ts; } return toSearchResult(/*value*/ undefined); } - var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) + return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); } else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null if (!Array.isArray(target)) { - for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { - var key = _c[_i]; + for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) { + var key = _a[_i]; if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { var subTarget = target[key]; var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); @@ -44013,8 +44097,8 @@ var ts; } return toSearchResult(/*value*/ undefined); } - for (var _d = 0, target_2 = target; _d < target_2.length; _d++) { - var elem = target_2[_d]; + for (var _b = 0, target_2 = target; _b < target_2.length; _b++) { + var elem = target_2[_b]; var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); if (result) { return result; @@ -44032,6 +44116,128 @@ var ts; trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(/*value*/ undefined); + function toAbsolutePath(path) { + var _a, _b; + if (path === undefined) + return path; + return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a))); + } + function combineDirectoryPath(root, dir) { + return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir)); + } + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) { + var _a, _b, _c, _d; + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames }); + var commonSourceDirGuesses = []; + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory + var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts")); + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + var fragment = ts.ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + var parts = ts.getPathComponents(fragment); + parts.pop(); // remove a directory + var commonDir_1 = ts.getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir_1); + fragment = ts.ensureTrailingDirectorySeparator(commonDir_1); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(ts.createCompilerDiagnostic(isImports + ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath)); + } + for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) { + var commonSourceDirGuess = commonSourceDirGuesses_1[_i]; + var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) { + var candidateDir = candidateDirectories_1[_e]; + if (ts.startsWith(finalPath, candidateDir)) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator + var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; + for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { + var ext = jsAndDtsExtensions_1[_f]; + if (ts.fileExtensionIs(possibleInputBase, ext)) { + var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) { + var possibleExt = inputExts_1[_g]; + var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state))); + } + } + } + } + } + } + } + } + return undefined; + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) { + var _a, _b; + // Config file ouput paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess; + var candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } /* @internal */ @@ -44179,7 +44385,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44222,11 +44428,12 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -44269,9 +44476,10 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; /** @@ -44297,14 +44505,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44315,34 +44523,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44350,21 +44558,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44372,16 +44580,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -44401,7 +44609,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -44412,7 +44620,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -44486,8 +44694,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -44509,7 +44717,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -44536,7 +44744,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -44556,33 +44764,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -44608,36 +44816,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(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; @@ -44656,14 +44864,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -44690,11 +44898,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -44706,20 +44914,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -44739,7 +44947,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -44747,9 +44955,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -44762,7 +44970,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -44776,9 +44984,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -44802,11 +45010,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -44833,7 +45041,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -44866,21 +45074,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -44888,22 +45096,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -44911,21 +45119,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -44939,10 +45147,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -44952,8 +45160,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -44976,59 +45184,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45038,47 +45246,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45092,22 +45300,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45115,7 +45323,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45131,7 +45339,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45142,68 +45350,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45215,7 +45423,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45227,7 +45435,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45242,28 +45450,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45273,7 +45481,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45292,8 +45500,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45307,7 +45515,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45358,12 +45566,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45385,7 +45593,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -45402,7 +45610,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -45473,7 +45681,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -45507,7 +45715,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -45536,7 +45744,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -45555,9 +45763,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -45581,7 +45789,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -45590,12 +45798,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -45603,16 +45811,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -45620,7 +45828,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -45631,15 +45839,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -45649,14 +45857,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -45705,9 +45913,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -45724,7 +45932,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -45738,7 +45946,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -45749,10 +45957,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -45777,7 +45985,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -45805,7 +46013,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -45834,7 +46042,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -45846,28 +46054,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -45893,8 +46101,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -45932,76 +46140,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46018,9 +46226,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46034,46 +46242,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46100,17 +46308,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46118,25 +46326,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46144,8 +46352,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46155,10 +46363,10 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } @@ -46172,7 +46380,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */ || prop.name.kind !== 79 /* SyntaxKind.Identifier */) { continue; } var identifier = prop.name; @@ -46184,9 +46392,9 @@ 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 === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + var currentKind = prop.kind === 296 /* SyntaxKind.PropertyAssignment */ || prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || prop.kind === 169 /* SyntaxKind.MethodDeclaration */ + ? 1 /* ElementKind.Property */ + : 2 /* ElementKind.Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -46194,17 +46402,17 @@ var ts; } } } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46212,10 +46420,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46241,9 +46449,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46254,8 +46462,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46263,29 +46471,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46303,24 +46511,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46362,7 +46570,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46373,7 +46581,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -46412,10 +46620,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -46425,7 +46633,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -46441,7 +46649,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -46454,7 +46662,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -46512,11 +46720,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -46526,7 +46734,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -46574,7 +46782,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -46583,28 +46791,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -46616,28 +46824,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -46648,94 +46856,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -46745,73 +46953,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -46822,27 +47030,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -46862,28 +47070,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -46902,13 +47110,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -46919,15 +47127,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -46948,13 +47156,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -46966,11 +47174,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -46984,17 +47192,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47003,19 +47211,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47023,7 +47231,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47032,10 +47240,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47054,7 +47262,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47075,7 +47283,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47087,7 +47295,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47100,7 +47308,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47118,13 +47326,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47138,7 +47346,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47150,12 +47358,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47165,27 +47373,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -47204,7 +47412,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47219,7 +47427,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47264,12 +47472,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47285,7 +47493,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47298,19 +47506,19 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47322,72 +47530,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -47401,45 +47609,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -47453,9 +47661,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -47479,17 +47687,17 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } @@ -47574,32 +47782,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -47688,7 +47896,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -47822,24 +48030,24 @@ var ts; TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = new ts.Map(ts.getEntries({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ + string: 1 /* TypeFacts.TypeofEQString */, + number: 2 /* TypeFacts.TypeofEQNumber */, + bigint: 4 /* TypeFacts.TypeofEQBigInt */, + boolean: 8 /* TypeFacts.TypeofEQBoolean */, + symbol: 16 /* TypeFacts.TypeofEQSymbol */, + undefined: 65536 /* TypeFacts.EQUndefined */, + object: 32 /* TypeFacts.TypeofEQObject */, + function: 64 /* TypeFacts.TypeofEQFunction */ })); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -47945,10 +48153,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -47973,8 +48181,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -47989,7 +48197,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48023,7 +48231,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48037,20 +48245,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48102,10 +48310,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48200,7 +48408,7 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); @@ -48221,13 +48429,13 @@ var ts; getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48313,7 +48521,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48350,10 +48558,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -48424,32 +48632,32 @@ var ts; var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var nonInferrableAnyType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 65536 /* ObjectFlags.ContainsWideningType */); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -48459,27 +48667,28 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonInferrableType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48487,7 +48696,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48495,11 +48704,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -48647,7 +48856,7 @@ var ts; var enumRelation = new ts.Map(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -48658,7 +48867,7 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; @@ -48804,7 +49013,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -48818,44 +49027,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -48887,13 +49096,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -48901,7 +49110,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -48924,7 +49133,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -48933,8 +49142,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -48945,9 +49154,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -48990,7 +49199,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49032,7 +49241,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49041,7 +49250,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49056,9 +49265,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49091,7 +49300,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49101,17 +49310,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49131,8 +49340,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49146,7 +49355,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49160,17 +49369,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49184,7 +49393,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49200,19 +49409,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49227,9 +49436,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49257,7 +49466,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49272,7 +49481,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49295,19 +49504,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49332,7 +49541,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49347,30 +49556,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -49423,35 +49632,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -49466,17 +49675,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -49496,13 +49705,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -49511,12 +49720,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -49526,20 +49735,20 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -49554,7 +49763,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -49562,11 +49771,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -49582,39 +49791,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -49622,7 +49831,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -49631,7 +49840,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -49646,20 +49855,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -49667,7 +49876,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -49675,8 +49884,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -49701,7 +49910,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -49738,7 +49947,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -49765,7 +49974,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -49788,22 +49997,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -49815,10 +50024,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -49832,31 +50041,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -49869,7 +50078,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -49913,7 +50122,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -49925,10 +50134,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -49938,9 +50147,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -49959,9 +50168,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -49972,20 +50181,20 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50007,7 +50216,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50024,15 +50233,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50042,29 +50251,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50085,13 +50294,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50116,22 +50325,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { @@ -50145,7 +50354,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50158,7 +50367,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50170,14 +50379,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50187,7 +50396,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -50204,7 +50413,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50236,7 +50445,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50244,7 +50453,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50272,12 +50481,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50321,7 +50530,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50336,7 +50545,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50344,7 +50553,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50360,7 +50569,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50369,7 +50578,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -50378,7 +50587,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -50399,7 +50608,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -50416,7 +50625,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -50496,7 +50705,7 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -50508,7 +50717,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -50516,31 +50725,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -50551,38 +50760,38 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol) { var links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } return undefined; @@ -50625,7 +50834,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -50633,7 +50842,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -50644,7 +50853,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -50665,7 +50874,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -50688,22 +50897,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -50713,7 +50922,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -50734,9 +50943,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -50744,9 +50953,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -50780,7 +50989,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -50788,8 +50997,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -50803,8 +51012,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -50824,7 +51033,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -50845,7 +51054,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -50876,7 +51085,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -50936,7 +51145,7 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; @@ -50945,9 +51154,6 @@ var ts; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) { - error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -51000,7 +51206,7 @@ var ts; var tsExtension = ts.tryExtractTSExtension(moduleReference); var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 || moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -51011,27 +51217,27 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); var suggestedExt = (_h = suggestedExtensions.find(function (_a) { var actualExt = _a[0], _importExt = _a[1]; return host.fileExists(absoluteRef_1 + actualExt); })) === null || _h === void 0 ? void 0 : _h[1]; if (suggestedExt) { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -51063,27 +51269,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51097,7 +51303,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51116,12 +51322,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51153,7 +51359,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51205,15 +51411,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51228,7 +51434,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51263,7 +51469,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51352,21 +51558,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -51390,7 +51596,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -51411,7 +51617,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -51419,7 +51625,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -51429,7 +51635,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -51453,16 +51659,16 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol)); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && !getTypeOnlyAliasDeclaration(symbol)); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -51485,7 +51691,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -51499,7 +51705,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -51509,11 +51715,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -51545,14 +51751,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -51570,12 +51776,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -51584,9 +51790,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -51597,7 +51803,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -51616,7 +51822,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -51627,7 +51833,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -51671,9 +51877,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -51681,7 +51887,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -51725,7 +51931,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -51740,10 +51946,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -51754,16 +51960,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -51793,7 +51999,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -51817,14 +52023,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -51853,7 +52059,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -51862,28 +52068,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -51891,24 +52097,24 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + else if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement && ts.isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); @@ -51932,83 +52138,83 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52016,7 +52222,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52034,17 +52240,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 814775659 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52078,12 +52284,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52105,7 +52311,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52140,62 +52346,62 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52209,66 +52415,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52278,19 +52484,19 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52307,8 +52513,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52316,43 +52522,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52360,39 +52566,63 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); + var name = typeParameterToName(newParam, context); + var newTypeVariable = ts.factory.createTypeReferenceNode(name); + context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var saveInferTypeParameters_1 = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters_1; + var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive + // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType + // inner conditional runs the check the user provided on the check type (distributively) and returns the result + // checkType extends infer T ? T extends checkType ? T extends extendsType ? trueType : falseType : never : never; + // this is potentially simplifiable to + // checkType extends infer T ? T extends checkType & extendsType ? trueType : falseType : never; + // but that may confuse users who read the output more. + // On the other hand, + // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; + // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); + } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -52403,7 +52633,7 @@ var ts; return typeToTypeNodeHelper(type, context); } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -52411,27 +52641,27 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -52440,16 +52670,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */ && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -52458,7 +52688,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -52474,26 +52704,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -52505,7 +52735,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -52564,20 +52794,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -52586,8 +52816,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -52599,27 +52829,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -52627,7 +52857,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -52635,23 +52865,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -52675,8 +52905,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -52688,8 +52918,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -52753,17 +52983,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -52773,16 +53003,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -52793,10 +53023,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -52806,19 +53036,19 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; - if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { + if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* CheckFlags.Late */ && isLateBoundName(propertySymbol.escapedName)) { if (propertySymbol.declarations) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { @@ -52841,12 +53071,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -52860,12 +53090,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -52874,11 +53104,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -52897,12 +53127,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -52911,7 +53141,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -52936,7 +53166,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -52971,22 +53201,22 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -52994,7 +53224,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); var thisParameter = tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); @@ -53002,11 +53232,11 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53017,28 +53247,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53062,7 +53292,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53076,29 +53306,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */); - } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -53118,7 +53345,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53127,9 +53354,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53139,8 +53366,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53150,7 +53377,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -53169,8 +53396,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -53189,7 +53416,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53219,7 +53446,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53234,11 +53461,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53258,11 +53485,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53314,7 +53541,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53322,8 +53549,8 @@ var ts; return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier; } 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 - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53332,7 +53559,7 @@ var ts; var targetFile = ts.getSourceFileOfModule(chain[0]); var specifier = void 0; var assertion = void 0; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) { specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext); @@ -53344,9 +53571,9 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -53405,16 +53632,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -53433,7 +53660,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -53445,7 +53672,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -53458,9 +53685,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -53469,23 +53696,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -53502,7 +53729,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -53510,13 +53737,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -53528,38 +53755,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -53588,7 +53815,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -53598,8 +53825,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -53633,7 +53860,7 @@ var ts; return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -53645,7 +53872,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_6) { return result_6; @@ -53654,20 +53881,30 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; return result; } + function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { + var typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; + } + return false; + } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -53686,20 +53923,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -53717,17 +53954,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -53741,11 +53978,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -53762,16 +53999,16 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -53780,7 +54017,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -53795,17 +54032,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -53836,8 +54073,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -53850,10 +54087,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -53868,16 +54105,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -53894,7 +54131,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -53910,9 +54147,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54008,11 +54245,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54065,37 +54302,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54107,21 +54344,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54133,14 +54370,14 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -54166,7 +54403,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -54174,11 +54411,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -54191,20 +54428,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54213,18 +54450,18 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54237,7 +54474,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54251,23 +54488,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54283,14 +54520,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54301,10 +54538,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); @@ -54313,7 +54550,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54326,7 +54563,7 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); @@ -54334,7 +54571,7 @@ var ts; var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -54350,12 +54587,12 @@ var ts; })))]); addResult(ts.factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { addResult(ts.factory.createEnumDeclaration( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -54367,22 +54604,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -54416,7 +54653,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -54437,15 +54674,15 @@ var ts; var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -54494,7 +54731,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -54521,17 +54758,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -54574,15 +54811,15 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -54590,19 +54827,19 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -54613,7 +54850,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, @@ -54622,30 +54859,30 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -54653,21 +54890,21 @@ var ts; // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -54676,9 +54913,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -54686,16 +54923,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -54710,18 +54947,18 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -54736,7 +54973,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -54750,7 +54987,7 @@ var ts; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -54766,7 +55003,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -54781,17 +55018,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -54811,11 +55048,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -54826,25 +55063,25 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -54853,8 +55090,8 @@ var ts; /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); @@ -54863,19 +55100,19 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -54885,7 +55122,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -54894,7 +55131,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -54902,13 +55139,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -54929,7 +55166,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -54965,15 +55202,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -54983,22 +55220,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55016,7 +55253,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55025,17 +55262,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55054,14 +55291,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55071,10 +55308,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55086,25 +55323,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55112,27 +55349,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55144,9 +55381,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55160,9 +55397,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55175,17 +55412,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -55202,84 +55439,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55288,11 +55525,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55316,7 +55553,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55365,23 +55602,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -55398,12 +55635,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -55428,28 +55665,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -55457,9 +55694,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -55474,7 +55711,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -55489,15 +55726,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -55533,34 +55770,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -55571,18 +55808,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -55599,7 +55836,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -55607,7 +55844,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -55619,7 +55856,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -55633,9 +55870,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 32768 /* TypeFlags.Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -55646,11 +55883,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -55661,11 +55898,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -55687,11 +55924,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -55703,8 +55940,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -55722,7 +55959,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -55745,14 +55982,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -55781,7 +56018,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -55803,7 +56040,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -55863,7 +56100,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -55902,7 +56139,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -55932,12 +56169,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -55961,7 +56198,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56017,13 +56254,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56035,7 +56272,7 @@ var ts; var _a; var exportedMember = members_4.get(name); if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56068,9 +56305,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56082,16 +56319,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56111,7 +56348,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56129,7 +56366,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56139,11 +56376,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56153,7 +56390,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56161,18 +56398,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56186,7 +56423,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -56200,7 +56437,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56210,14 +56447,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56234,7 +56471,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56258,14 +56495,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56306,15 +56543,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56333,7 +56570,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56347,10 +56584,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -56373,7 +56610,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -56382,7 +56619,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -56407,11 +56644,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -56446,10 +56683,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -56464,8 +56701,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -56486,21 +56723,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -56508,13 +56745,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -56535,7 +56772,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -56556,7 +56793,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -56569,7 +56806,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -56578,7 +56815,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -56589,15 +56826,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -56605,56 +56842,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -56677,7 +56914,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -56688,46 +56925,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -56738,7 +56975,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -56751,9 +56988,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -56770,7 +57007,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -56781,10 +57018,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -56797,7 +57034,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -56820,7 +57057,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -56828,7 +57065,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -56837,13 +57074,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -56883,19 +57120,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -56905,7 +57142,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -56916,26 +57153,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -56960,7 +57197,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -56985,7 +57222,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -56993,15 +57230,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57041,8 +57278,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57050,8 +57287,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57065,7 +57302,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57079,8 +57316,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57101,7 +57338,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57120,7 +57357,7 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { @@ -57135,7 +57372,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57143,19 +57380,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57170,11 +57407,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -57183,23 +57420,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57211,15 +57448,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57245,22 +57482,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57272,22 +57509,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57313,7 +57550,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57329,14 +57566,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -57373,8 +57610,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -57383,7 +57620,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -57402,9 +57639,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -57429,10 +57666,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -57443,7 +57680,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -57452,7 +57689,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -57501,7 +57738,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -57510,10 +57747,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -57531,9 +57768,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -57559,10 +57796,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -57578,8 +57815,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -57589,7 +57826,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -57606,7 +57843,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -57614,7 +57851,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -57650,8 +57887,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -57686,7 +57923,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -57696,24 +57933,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -57725,7 +57962,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -57738,10 +57975,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -57749,11 +57986,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -57768,7 +58005,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -57931,12 +58168,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -57958,11 +58195,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -57987,8 +58224,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -57996,7 +58233,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58011,7 +58248,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58033,7 +58270,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58043,7 +58280,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58082,18 +58319,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58106,7 +58343,8 @@ var ts; if (symbol === globalThisSymbol) { var varsOnly_1 = new ts.Map(); members.forEach(function (p) { - if (!(p.flags & 418 /* BlockScoped */)) { + var _a; + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58115,10 +58353,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58134,8 +58372,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58144,16 +58382,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58171,20 +58409,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58205,11 +58443,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58219,29 +58457,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58261,7 +58499,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58289,13 +58527,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58308,12 +58546,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58321,7 +58559,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58331,8 +58569,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -58358,7 +58596,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -58366,8 +58604,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -58383,20 +58621,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -58404,34 +58642,34 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -58439,7 +58677,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -58448,7 +58686,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58472,7 +58710,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -58482,13 +58720,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -58507,7 +58745,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -58526,9 +58764,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -58589,7 +58827,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -58607,11 +58845,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -58621,7 +58859,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { hasDisjointDomainType = true; } } @@ -58633,7 +58871,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -58643,11 +58881,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -58672,7 +58910,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -58682,13 +58920,14 @@ var ts; // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of // nesting, so it is effectively just a safety stop. - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + var identity_1 = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) { + stack.push(identity_1); result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -58708,13 +58947,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -58734,23 +58973,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -58761,11 +59000,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -58824,7 +59063,7 @@ var ts; var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -58832,7 +59071,7 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !objectType.declaration.questionToken && !objectType.declaration.nameType); } @@ -58842,17 +59081,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ScriptTarget.ES2020 */) : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ScriptTarget.ES2015 */) : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -58867,21 +59106,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -58894,7 +59133,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -58912,41 +59151,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -58988,18 +59227,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59012,7 +59251,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59046,7 +59285,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59055,15 +59294,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59073,7 +59312,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59084,23 +59323,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59115,7 +59354,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59135,15 +59374,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -59186,13 +59425,13 @@ var ts; } function isApplicableIndexType(source, target) { // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index - // signature applies to types assignable to 'number' and numeric string literal types. + // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59243,17 +59482,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59268,7 +59507,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59286,7 +59525,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59335,7 +59574,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59347,7 +59586,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -59357,19 +59596,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -59381,25 +59620,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -59421,7 +59660,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -59430,7 +59669,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -59463,7 +59702,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -59475,18 +59714,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -59558,26 +59797,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -59604,7 +59843,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -59614,12 +59853,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -59628,7 +59867,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -59722,8 +59961,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -59737,7 +59976,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -59755,7 +59994,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -59770,8 +60009,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -59782,13 +60021,13 @@ var ts; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -59813,27 +60052,27 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -59858,10 +60097,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -59870,7 +60109,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -59898,7 +60137,7 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -59912,13 +60151,13 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; @@ -59940,7 +60179,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -59951,13 +60190,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -59992,14 +60231,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60030,12 +60269,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60070,9 +60309,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60084,21 +60323,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60120,10 +60359,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60131,14 +60370,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60154,7 +60393,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60165,22 +60404,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -60190,27 +60429,41 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); } } + // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the + // template type XXX, K has an added constraint of number | `${number}`. + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { + var mappedType = getTypeFromTypeNode(parent); + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + var typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + var constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = ts.append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60266,7 +60519,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60278,13 +60531,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60325,9 +60578,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60337,7 +60590,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -60348,13 +60601,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -60390,9 +60643,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -60457,7 +60710,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -60495,20 +60748,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -60517,14 +60770,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -60533,18 +60786,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -60553,28 +60806,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -60587,33 +60840,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -60631,7 +60884,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -60641,8 +60894,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -60650,8 +60903,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -60661,7 +60914,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -60679,26 +60932,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -60717,10 +60970,10 @@ var ts; var _loop_15 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -60735,7 +60988,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -60750,12 +61003,12 @@ var ts; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -60765,13 +61018,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -60823,19 +61076,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -60869,18 +61122,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -60894,20 +61147,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -60925,11 +61178,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -60943,7 +61196,7 @@ var ts; var _loop_16 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; @@ -60953,17 +61206,17 @@ var ts; } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -60982,7 +61235,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -60991,37 +61244,37 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; @@ -61045,11 +61298,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61058,8 +61311,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61096,20 +61349,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61120,41 +61373,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -61172,10 +61425,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -61188,10 +61441,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61205,11 +61458,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61226,7 +61479,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61238,7 +61491,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61247,7 +61500,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61276,12 +61529,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61310,37 +61563,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { + if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -61352,21 +61605,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -61378,8 +61631,8 @@ var ts; var constituents = getCrossProductIntersections(typeSet); // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions). - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -61390,12 +61643,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -61408,7 +61661,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -61416,7 +61669,7 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; @@ -61430,13 +61683,13 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -61468,7 +61721,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -61484,8 +61737,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -61505,12 +61758,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -61522,11 +61775,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -61536,14 +61789,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -61561,16 +61814,16 @@ var ts; function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) + return type.flags & 1048576 /* TypeFlags.Union */ ? isPossiblyReducibleByInstantiation(type) ? getIndexTypeForGenericType(type, stringsOnly) : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -61581,21 +61834,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -61612,7 +61865,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -61631,10 +61884,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -61645,13 +61898,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -61664,7 +61917,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -61677,35 +61930,35 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -61713,13 +61966,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -61740,16 +61993,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -61764,26 +62017,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -61793,7 +62046,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -61801,12 +62054,12 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -61818,33 +62071,33 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -61852,21 +62105,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -61888,20 +62141,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -61918,10 +62171,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -61939,62 +62192,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62019,7 +62272,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62033,17 +62286,20 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } } - // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where + // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P. + // For example, for an index access { [P in K]: Box }[X], we construct the type Box. + if (isGenericMappedType(objectType)) { + var nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + } } return type[cache] = type; } @@ -62053,19 +62309,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62075,7 +62331,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62083,12 +62339,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62099,33 +62355,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -62137,12 +62393,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -62158,11 +62414,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -62170,8 +62426,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -62181,7 +62437,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -62193,11 +62449,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62262,7 +62518,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62280,7 +62536,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62296,15 +62552,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -62322,7 +62578,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -62333,7 +62589,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -62361,14 +62617,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -62396,7 +62652,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -62419,7 +62675,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -62462,7 +62718,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -62475,7 +62731,7 @@ var ts; var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references @@ -62498,7 +62754,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -62512,7 +62768,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -62528,7 +62784,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -62541,7 +62797,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -62550,13 +62806,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -62576,13 +62832,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62591,7 +62847,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -62601,31 +62857,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -62635,7 +62891,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -62649,7 +62905,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -62664,11 +62920,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -62681,23 +62937,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62715,7 +62971,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -62726,39 +62982,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -62768,9 +63024,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -62786,20 +63042,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -62821,17 +63077,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -62847,99 +63103,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -62977,9 +63233,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -62988,22 +63244,22 @@ var ts; } } return type; - case 2 /* Function */: + case 2 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 3 /* TypeMapKind.Composite */: + case 4 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 3 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return { kind: 0 /* TypeMapKind.Simple */, source: source, target: target }; } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return { kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }; } function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + return { kind: 2 /* TypeMapKind.Function */, func: func }; } function makeCompositeTypeMapper(kind, mapper1, mapper2) { return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; @@ -63019,16 +63275,16 @@ var ts; return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(3 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63061,7 +63317,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63073,7 +63329,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63082,7 +63338,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63096,12 +63352,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63114,8 +63370,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -63136,8 +63392,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -63146,8 +63402,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -63156,7 +63412,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -63165,15 +63421,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -63184,9 +63440,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63208,11 +63464,11 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -63232,7 +63488,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63241,14 +63497,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63258,11 +63514,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63272,13 +63528,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63287,7 +63543,7 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; @@ -63312,7 +63568,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -63332,7 +63588,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -63345,62 +63601,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -63410,11 +63666,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -63424,15 +63680,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -63453,35 +63709,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -63495,17 +63751,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -63514,7 +63770,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -63524,13 +63780,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -63547,11 +63803,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -63589,7 +63845,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -63599,35 +63855,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -63651,7 +63907,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -63669,7 +63925,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -63686,7 +63942,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -63696,7 +63952,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -63713,7 +63969,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -63733,8 +63989,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -63758,7 +64014,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -63824,18 +64080,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -63860,7 +64116,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -63942,7 +64198,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -63952,7 +64208,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -63977,17 +64233,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64009,7 +64265,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64021,8 +64277,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64038,16 +64294,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64059,10 +64315,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64074,7 +64330,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64093,27 +64349,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* TypeFlags.Nullable */) === (getFalsyFlags(targetType) & 98304 /* TypeFlags.Nullable */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -64136,14 +64392,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -64158,21 +64414,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -64198,19 +64454,19 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64219,83 +64475,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; } return false; @@ -64311,38 +64567,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getReducedType(type) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) @@ -64371,19 +64627,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -64421,10 +64677,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -64469,24 +64725,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -64515,7 +64771,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -64528,7 +64784,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -64580,7 +64836,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperType && target !== markerSubType) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -64602,7 +64858,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -64650,7 +64906,7 @@ var ts; } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -64664,7 +64920,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -64673,19 +64929,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -64694,73 +64950,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -64779,10 +65035,10 @@ var ts; // // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. - if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -64792,10 +65048,9 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { - var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -64804,20 +65059,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -64836,25 +65091,22 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -64869,7 +65121,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -64877,19 +65129,19 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_19 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { @@ -64944,7 +65196,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -64967,28 +65219,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -64996,16 +65248,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65013,13 +65265,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65027,7 +65279,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65036,19 +65288,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65056,50 +65308,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65110,54 +65362,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65171,28 +65423,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); } - if (saved & 16 /* ReportsUnreliable */) { + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65208,42 +65460,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65251,30 +65503,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -65283,14 +65535,14 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; @@ -65300,29 +65552,29 @@ var ts; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -65330,18 +65582,18 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { + if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -65355,10 +65607,10 @@ var ts; // needs to have its constraint hoisted into an intersection with said type parameter, this way // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65370,20 +65622,20 @@ var ts; // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -65392,34 +65644,34 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65432,8 +65684,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -65448,7 +65700,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -65456,18 +65708,18 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65485,14 +65737,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -65511,12 +65763,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -65524,22 +65776,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65559,7 +65811,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -65569,12 +65821,12 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -65585,8 +65837,8 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { resetErrorInfo(saveErrorInfo); return result; @@ -65594,37 +65846,37 @@ var ts; } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source); - if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) { + if (!constraint || (sourceFlags & 262144 /* TypeFlags.TypeParameter */ && constraint.flags & 1 /* TypeFlags.Any */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* TypeFlags.NonPrimitive */), 3 /* RecursionFlags.Both */)) { resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65633,7 +65885,7 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65641,44 +65893,44 @@ var ts; } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */ && source.symbol === target.symbol) { + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -65687,15 +65939,15 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65708,7 +65960,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65718,7 +65970,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65727,7 +65979,7 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -65736,22 +65988,22 @@ var ts; return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -65761,41 +66013,41 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -65812,9 +66064,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -65822,7 +66074,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -65832,7 +66084,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -65859,8 +66111,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -65892,14 +66144,14 @@ var ts; var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -65914,7 +66166,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -65926,8 +66178,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -65936,7 +66188,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -65957,7 +66209,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -65974,7 +66226,7 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { @@ -65984,20 +66236,20 @@ var ts; return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66024,40 +66276,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66067,7 +66319,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66075,10 +66327,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -66089,7 +66341,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -66100,7 +66352,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -66142,29 +66394,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -66175,38 +66427,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66214,12 +66466,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66229,14 +66481,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66245,18 +66497,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -66268,12 +66520,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66282,24 +66534,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66311,17 +66563,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -66330,18 +66582,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -66349,7 +66601,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66364,10 +66616,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -66393,18 +66645,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -66427,45 +66679,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66475,7 +66727,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66483,7 +66735,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -66500,14 +66752,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66518,46 +66770,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -66570,19 +66822,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -66591,7 +66843,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -66611,7 +66863,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -66646,12 +66898,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -66667,7 +66919,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -66683,14 +66935,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; var _loop_22 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -66701,22 +66953,22 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } @@ -66737,7 +66989,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -66748,34 +67000,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -66783,7 +67035,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -66819,12 +67071,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -66839,7 +67091,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } // Return the inherited type of the given property or undefined if property doesn't exist in a base class. function getTypeOfPropertyInBaseClass(property) { @@ -66857,13 +67109,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -66881,12 +67133,12 @@ var ts; function isDeeplyNestedType(type, stack, depth, maxDepth) { if (maxDepth === void 0) { maxDepth = 3; } if (depth >= maxDepth) { - var identity_1 = getRecursionIdentity(type); + var identity_2 = getRecursionIdentity(type); var count = 0; var lastTypeId = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (getRecursionIdentity(t) === identity_1) { + if (getRecursionIdentity(t) === identity_2) { // We only count occurrences with a higher type id than the previous occurrence, since higher // type ids are an indicator of newer instantiations caused by recursion. if (t.id >= lastTypeId) { @@ -66909,14 +67161,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -66926,49 +67178,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -66999,14 +67251,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67017,12 +67269,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67030,7 +67282,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67042,7 +67294,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67056,10 +67308,10 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -67090,20 +67342,23 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : - getUnionType(types, 2 /* Subtype */); + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* TypeFlags.Nullable */) : + getUnionType(types, 2 /* UnionReduction.Subtype */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; + } + function isArrayOrTupleType(type) { + return isArrayType(type) || isTupleType(type); } function isMutableArrayOrTuple(type) { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; @@ -67114,22 +67369,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -67144,7 +67399,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -67171,44 +67426,44 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getBaseTypeOfLiteralType) : type; } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67239,10 +67494,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -67263,7 +67518,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -67271,7 +67526,7 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; @@ -67289,31 +67544,31 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 : - type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 : - type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 : - type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 : - type.flags & 117724 /* PossiblyFalsy */; + return type.flags & 1048576 /* TypeFlags.Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value === "" ? 128 /* TypeFlags.StringLiteral */ : 0 : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? type.value === 0 ? 256 /* TypeFlags.NumberLiteral */ : 0 : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* TypeFlags.BigIntLiteral */ : 0 : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* TypeFlags.BooleanLiteral */ : 0 : + type.flags & 117724 /* TypeFlags.PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* TypeFlags.DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* TypeFlags.DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -67322,24 +67577,24 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' // that isn't eliminated by a NonNullable instantiation. - var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + var reducedType = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? @@ -67367,10 +67622,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -67393,23 +67648,23 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -67439,7 +67694,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -67450,7 +67705,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -67480,7 +67735,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -67492,7 +67747,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -67508,7 +67763,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -67527,36 +67782,36 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -67579,8 +67834,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -67593,7 +67848,7 @@ var ts; } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { @@ -67605,7 +67860,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -67624,17 +67879,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -67645,25 +67900,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -67672,10 +67927,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -67687,7 +67942,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -67790,9 +68045,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -67838,40 +68093,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? false : "quit"; })); } return false; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || - type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -67879,7 +68134,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -67907,7 +68162,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -67924,14 +68179,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -67966,7 +68221,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -67976,9 +68231,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -67996,7 +68251,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68007,7 +68262,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68029,12 +68284,12 @@ var ts; sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); } function isValidBigIntString(s) { - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - if (result === 40 /* MinusToken */) { + if (result === 40 /* SyntaxKind.MinusToken */) { result = scanner.scan(); } var flags = scanner.getTokenFlags(); @@ -68043,27 +68298,27 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */); } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || - target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + return !!(target.flags & 8 /* TypeFlags.Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* TypeFlags.BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -68073,7 +68328,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -68155,12 +68410,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -68182,7 +68437,7 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -68191,10 +68446,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68209,21 +68464,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -68231,10 +68486,10 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -68242,12 +68497,12 @@ var ts; // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* InferencePriority.ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -68272,7 +68527,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -68285,11 +68540,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -68297,45 +68552,45 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); contravariant = !contravariant; } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); var oldPriority = priority; - priority |= 4 /* SubstituteSource */; + priority |= 4 /* InferencePriority.SubstituteSource */; inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority priority = oldPriority; } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -68343,17 +68598,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -68366,7 +68621,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -68384,19 +68639,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -68404,7 +68659,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -68432,7 +68687,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -68441,7 +68696,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -68451,7 +68706,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -68465,7 +68720,7 @@ var ts; var typeVariable; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -68475,9 +68730,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -68493,11 +68748,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -68508,7 +68763,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -68542,17 +68797,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -68560,7 +68815,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -68572,17 +68827,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -68601,7 +68856,7 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); @@ -68609,7 +68864,7 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; @@ -68631,7 +68886,7 @@ var ts; } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -68646,7 +68901,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -68654,7 +68909,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); @@ -68669,21 +68924,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -68692,14 +68947,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -68719,8 +68974,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -68740,7 +68995,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -68748,9 +69003,9 @@ var ts; function inferFromSignature(source, target, skipParameters) { if (!skipParameters) { var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -68758,7 +69013,7 @@ var ts; } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -68766,9 +69021,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -68793,34 +69048,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -68837,8 +69092,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -68852,14 +69107,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -68880,7 +69135,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -68950,7 +69205,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -68962,7 +69217,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -68971,7 +69226,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -68979,22 +69234,22 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -69005,44 +69260,44 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -69063,15 +69318,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -69110,12 +69365,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -69145,7 +69400,7 @@ var ts; var map = new ts.Map(); var count = 0; var _loop_23 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -69181,15 +69436,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -69213,7 +69468,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -69230,7 +69485,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -69244,7 +69499,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69260,11 +69515,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { + if (assignedType.flags & 131072 /* TypeFlags.Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { + if (assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType)) { reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types } // Our crude heuristic produces an invalid result in some cases: see GH#26130. @@ -69287,93 +69542,93 @@ var ts; function getTypeFacts(type, ignoreObjects) { if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; - if (flags & 4 /* String */) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & 4 /* TypeFlags.String */) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & 128 /* StringLiteral */) { + if (flags & 128 /* TypeFlags.StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { if (ignoreObjects) { - return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection. + return 16768959 /* TypeFacts.AndFactsMask */; // This is the identity element for computing type facts of intersection. } - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 16318463 /* TypeFacts.EmptyObjectStrictFacts */ : 16777215 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { - return 9830144 /* UndefinedFacts */; + if (flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { + return 9830144 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 9363232 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 9363232 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 465829888 /* Instantiable */) { + if (flags & 465829888 /* TypeFlags.Instantiable */) { return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : - strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; + strictNullChecks ? 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */)); return getIntersectionTypeFacts(type, ignoreObjects); } - return 16777215 /* All */; + return 16777215 /* TypeFacts.All */; } function getIntersectionTypeFacts(type, ignoreObjects) { // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 16777215 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 16777215 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; var f = getTypeFacts(t, ignoreObjects); oredFacts |= f; andedFacts &= f; } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 16768959 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -69393,7 +69648,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -69404,18 +69659,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -69432,21 +69687,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -69454,7 +69709,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -69472,37 +69727,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -69510,13 +69765,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -69536,7 +69791,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -69549,13 +69804,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -69564,25 +69819,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -69590,45 +69845,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -69639,11 +69894,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -69655,13 +69910,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -69673,14 +69928,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -69695,10 +69950,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -69706,17 +69961,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { var t = types_18[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -69730,16 +69985,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -69748,11 +70003,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -69763,11 +70018,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -69782,16 +70037,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -69809,7 +70064,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -69823,10 +70078,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -69834,7 +70089,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -69844,10 +70099,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -69867,8 +70122,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -69876,7 +70131,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -69884,30 +70139,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -69915,7 +70170,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -69923,7 +70178,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -69934,7 +70189,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -69943,7 +70198,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -69951,24 +70206,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -69978,18 +70233,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -70015,8 +70270,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -70032,7 +70287,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -70041,7 +70296,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -70054,56 +70309,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -70127,7 +70382,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -70139,7 +70394,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -70150,7 +70405,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -70167,14 +70422,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -70182,14 +70437,14 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -70199,15 +70454,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : - predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -70216,15 +70471,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -70233,7 +70488,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -70247,7 +70502,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -70257,7 +70512,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -70272,16 +70527,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -70298,7 +70553,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -70342,7 +70597,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -70368,7 +70623,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -70421,7 +70676,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -70436,7 +70691,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -70482,8 +70737,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -70499,8 +70754,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -70508,16 +70763,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -70526,7 +70781,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -70537,52 +70792,52 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType : - getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return type.flags & 2 /* TypeFlags.Unknown */ && assumeTrue ? nonNullUnknownType : + getTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -70614,35 +70869,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -70675,48 +70930,48 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) { + if (assumeTrue && (type.flags & 2 /* TypeFlags.Unknown */) && (operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */) && (valueType.flags & 65536 /* TypeFlags.Null */)) { return getUnionType([nullType, undefinedType]); } - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; - return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; + return type.flags & 2 /* TypeFlags.Unknown */ && facts & (1048576 /* TypeFacts.NENull */ | 2097152 /* TypeFacts.NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -70728,34 +70983,34 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } - if (type.flags & 1 /* Any */ && literal.text === "function") { + if (type.flags & 1 /* TypeFlags.Any */ && literal.text === "function") { return type; } - if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { + if (assumeTrue && type.flags & 2 /* TypeFlags.Unknown */ && literal.text === "object") { // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null // unknown type, and then narrows that to the non-primitive type. return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeFacts.TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */; var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text); return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -70768,16 +71023,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -70790,20 +71045,20 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { switch (text) { case "function": - return type.flags & 1 /* Any */ ? type : globalFunctionType; + return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType; case "object": - return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; default: return typeofTypesByName.get(text); } @@ -70822,7 +71077,7 @@ var ts; if (isTypeSubtypeOf(candidate, type)) { return candidate; } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(candidate, constraint)) { return getIntersectionType([type, candidate]); @@ -70897,7 +71152,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -70927,8 +71182,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -70939,7 +71194,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -70962,13 +71217,13 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; @@ -70981,9 +71236,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { + if (!(assignableType.flags & 131072 /* TypeFlags.Never */)) { return assignableType; } } @@ -71001,7 +71256,7 @@ var ts; if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71011,7 +71266,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71026,8 +71281,8 @@ var ts; return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { @@ -71042,11 +71297,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -71062,20 +71317,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -71084,11 +71339,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -71099,7 +71354,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -71123,9 +71378,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -71135,8 +71390,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -71145,11 +71400,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -71162,18 +71417,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 32768 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -71185,17 +71440,17 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -71204,8 +71459,8 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) : getContextualType(node)); return contextualType && !isGenericType(contextualType); } @@ -71217,10 +71472,10 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); - return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (n) { @@ -71238,9 +71493,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -71283,16 +71538,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { - var links = getNodeLinks(location); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { + var links = getNodeLinks(parent); + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -71326,7 +71581,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -71357,15 +71612,15 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } // We should only mark aliases as referenced if there isn't a local value declaration @@ -71379,32 +71634,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -71416,19 +71671,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -71437,11 +71692,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -71458,17 +71713,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -71476,11 +71731,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -71497,7 +71752,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -71514,11 +71769,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -71533,12 +71788,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -71548,22 +71803,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -71573,7 +71828,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -71581,9 +71836,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -71593,13 +71848,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -71641,36 +71896,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -71705,7 +71960,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -71753,9 +72008,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -71763,31 +72018,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -71799,17 +72054,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -71819,18 +72074,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -71841,14 +72096,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -71856,26 +72111,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -71937,12 +72192,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -71951,8 +72206,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -71972,12 +72227,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -71987,7 +72242,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -71995,23 +72250,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72019,22 +72274,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -72061,7 +72316,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -72075,7 +72330,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -72103,7 +72358,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -72128,11 +72383,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -72143,10 +72398,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -72179,7 +72434,7 @@ var ts; if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } @@ -72191,8 +72446,8 @@ var ts; var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var use = functionFlags & 2 /* FunctionFlags.Async */ ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); if (!iterationTypes) { return undefined; @@ -72200,7 +72455,7 @@ var ts; contextualReturnType = iterationTypes.returnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72226,7 +72481,7 @@ var ts; if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); } } return undefined; @@ -72245,7 +72500,7 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); var contextualReturnType = getContextualReturnType(functionDecl); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) @@ -72292,11 +72547,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -72305,13 +72560,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -72320,8 +72575,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -72354,8 +72609,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -72365,11 +72620,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (decl.initializer && getTypeOfExpression(binaryExpression.left)); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -72390,7 +72645,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -72404,18 +72659,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -72423,14 +72678,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -72454,7 +72709,7 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { @@ -72467,7 +72722,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -72488,7 +72743,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72523,7 +72778,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -72578,29 +72833,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -72609,24 +72864,24 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. - if (contextFlags && contextFlags & 1 /* Signature */) { + if (contextFlags && contextFlags & 1 /* ContextFlags.Signature */) { return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); } // For other purposes (e.g. determining whether to produce literal types) we only @@ -72635,7 +72890,7 @@ var ts; // literals actually end up widening to 'boolean' (see #48363). if (inferenceContext.returnMapper) { var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -72647,13 +72902,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -72676,7 +72931,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72685,60 +72940,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -72751,7 +73006,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -72760,7 +73015,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -72805,7 +73060,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -72820,7 +73075,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -72921,12 +73176,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -72948,18 +73203,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -72989,16 +73244,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -73027,18 +73282,18 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -73051,14 +73306,14 @@ var ts; var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -73074,27 +73329,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -73108,28 +73363,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -73138,14 +73393,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -73156,17 +73411,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -73182,7 +73437,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -73194,11 +73449,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -73218,9 +73473,9 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -73242,16 +73497,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -73263,29 +73518,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -73300,17 +73555,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -73344,10 +73599,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -73372,11 +73627,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -73408,12 +73663,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -73423,8 +73678,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -73470,7 +73725,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -73494,15 +73749,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -73517,7 +73772,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -73533,6 +73788,7 @@ var ts; } } else { + error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -73543,7 +73799,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -73557,7 +73813,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -73585,7 +73841,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -73595,12 +73851,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -73612,7 +73868,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -73632,7 +73888,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -73651,13 +73907,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -73706,10 +73962,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -73722,7 +73978,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -73737,7 +73993,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -73761,7 +74017,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -73775,10 +74031,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -73791,12 +74047,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -73824,13 +74080,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -73861,10 +74117,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -73898,7 +74154,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -73916,20 +74172,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -73938,7 +74194,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -73963,7 +74219,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -73975,7 +74231,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -73986,10 +74242,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -74012,13 +74268,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -74032,9 +74288,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -74057,7 +74313,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -74065,7 +74321,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -74077,7 +74333,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -74088,12 +74344,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -74120,7 +74376,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -74128,10 +74384,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -74146,10 +74402,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -74159,39 +74415,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */; if (kind) { reportError(node, kind); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -74200,13 +74456,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -74219,7 +74475,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -74243,7 +74499,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -74315,16 +74571,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -74346,8 +74602,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -74363,15 +74619,20 @@ var ts; prop = getPropertyOfType(apparentType, right.escapedText); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined + // here even if `Foo` is not a const enum. + // // The exceptions are: // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. - if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -74379,7 +74640,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -74399,7 +74660,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -74411,7 +74672,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -74430,11 +74691,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -74444,12 +74705,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -74462,12 +74723,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -74480,7 +74741,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; @@ -74498,13 +74759,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -74515,25 +74776,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -74545,7 +74806,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -74570,7 +74831,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -74658,7 +74919,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -74669,7 +74930,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -74677,7 +74938,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -74696,7 +74957,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -74712,7 +74973,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -74743,7 +75004,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -74771,7 +75032,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -74781,16 +75042,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -74800,19 +75061,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -74827,7 +75088,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -74867,13 +75128,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -74890,13 +75151,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -74910,7 +75171,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -74919,7 +75180,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -74931,8 +75192,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -74945,13 +75206,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -75015,16 +75276,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -75032,9 +75293,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -75045,11 +75306,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -75063,7 +75324,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -75087,7 +75348,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -75103,20 +75364,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -75125,12 +75386,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -75138,7 +75399,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -75166,8 +75427,8 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { - var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); + if (node.kind !== 165 /* SyntaxKind.Decorator */) { + var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { @@ -75175,7 +75436,7 @@ var ts; // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. var outerContext = getInferenceContext(node); - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -75189,7 +75450,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of // the source type uses the outer context's return mapper (which excludes inferences made from @@ -75203,7 +75464,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -75216,7 +75477,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -75231,10 +75492,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -75242,7 +75503,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -75252,24 +75513,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -75299,16 +75560,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -75333,7 +75594,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -75341,12 +75602,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -75356,7 +75617,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -75413,7 +75674,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -75431,13 +75692,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -75476,8 +75737,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -75495,17 +75756,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -75519,12 +75780,12 @@ var ts; var _loop_24 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -75546,30 +75807,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -75583,17 +75844,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -75627,7 +75888,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -75669,8 +75930,14 @@ var ts; var parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && ts.isInJSFile(node)) { + return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + var error = hasRestParameter + ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : ts.Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { // between min and max, but with no matching overload @@ -75729,15 +75996,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -75764,7 +76031,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -75792,7 +76060,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -75825,7 +76093,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -75848,7 +76116,7 @@ var ts; var i_1 = 0; var _loop_25 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -75933,7 +76201,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -75956,9 +76224,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -75980,7 +76248,7 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = 0 /* Normal */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -76033,14 +76301,14 @@ var ts; _loop_26(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -76053,7 +76321,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -76090,8 +76358,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -76111,7 +76379,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -76126,7 +76394,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -76135,13 +76403,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -76156,8 +76424,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -76184,7 +76452,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -76200,7 +76468,7 @@ var ts; // use the resolvingSignature singleton to indicate that we deferred processing. This result will be // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -76221,11 +76489,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -76258,7 +76526,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -76267,24 +76535,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -76295,14 +76563,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -76310,7 +76578,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -76318,7 +76586,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -76341,9 +76609,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -76351,16 +76619,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -76369,10 +76637,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { @@ -76422,7 +76690,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -76466,8 +76734,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76477,26 +76745,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -76511,8 +76779,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76523,38 +76791,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -76575,7 +76843,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -76591,16 +76859,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -76623,7 +76891,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -76664,7 +76932,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -76700,16 +76968,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -76732,10 +77000,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -76755,15 +77023,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -76780,11 +77048,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -76797,14 +77065,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -76813,20 +77081,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -76848,7 +77116,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -76863,13 +77131,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -76885,11 +77153,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + newSymbol.aliasTarget = resolveSymbol(symbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -76912,7 +77180,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -76932,40 +77200,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -76973,31 +77241,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -77028,12 +77296,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -77058,7 +77326,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -77066,12 +77334,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -77080,10 +77348,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -77099,19 +77367,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -77124,7 +77392,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -77134,16 +77402,16 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -77176,7 +77444,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77208,7 +77476,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77258,11 +77526,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -77286,14 +77554,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -77301,7 +77569,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -77311,7 +77579,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -77341,7 +77609,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -77361,7 +77629,7 @@ var ts; } } var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { // The contextual signature has a generic rest parameter. We first instantiate the contextual // signature (without fixing type parameters) and assign types to contextually typed parameters. var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); @@ -77405,7 +77673,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -77425,7 +77693,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -77444,7 +77712,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -77492,8 +77760,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -77505,14 +77773,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -77527,36 +77795,36 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { @@ -77565,9 +77833,9 @@ var ts; contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -77581,7 +77849,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -77624,13 +77892,13 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { @@ -77644,7 +77912,7 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -77656,14 +77924,14 @@ var ts; * whether the active clause contains a default clause. */ function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; // When in the default we only collect inequality facts // because default is 'in theory' a set of infinite // equalities. if (hasDefault) { // Value is not equal to any types after the active clause. for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -77673,7 +77941,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -77681,7 +77949,7 @@ var ts; else { // Add equalities for all types in the active clause. for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeFacts.TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -77696,17 +77964,17 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); var type_6 = getBaseConstraintOfType(operandType) || operandType; // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types. - if (type_6.flags & 3 /* AnyOrUnknown */) { - return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */; + if (type_6.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_1) === 556800 /* TypeFacts.AllTypeofNE */; } - return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* TypeFlags.Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -77730,15 +77998,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -77759,11 +78027,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -77784,17 +78052,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -77823,13 +78091,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -77840,9 +78108,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -77850,7 +78118,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -77859,21 +78127,21 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); } var instantiatedContextualSignature = inferenceContext ? @@ -77896,7 +78164,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -77909,7 +78177,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -77921,7 +78189,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -77979,27 +78247,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -78020,11 +78288,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -78032,12 +78300,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -78066,8 +78334,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -78085,21 +78353,36 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = void 0; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -78109,7 +78392,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -78125,7 +78408,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -78136,16 +78419,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -78153,28 +78436,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -78197,8 +78480,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -78218,7 +78501,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var t = types_21[_i]; @@ -78233,30 +78516,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -78268,7 +78551,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -78282,8 +78565,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -78296,8 +78579,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -78322,9 +78605,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -78344,7 +78627,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -78355,17 +78638,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -78387,18 +78670,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -78407,15 +78690,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -78426,7 +78709,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -78442,14 +78725,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* TypeFlags.Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -78458,31 +78741,31 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -78497,59 +78780,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -78580,9 +78863,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -78599,8 +78882,8 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var parent = ts.walkUpParenthesizedExpressions(node.parent); checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } @@ -78660,11 +78943,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -78673,11 +78956,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -78689,28 +78972,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -78719,8 +79002,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -78731,21 +79014,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -78761,26 +79044,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -78798,21 +79081,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -78821,56 +79104,56 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -78880,7 +79163,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -78898,16 +79181,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -78917,12 +79200,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -78932,15 +79215,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -78959,7 +79242,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -78973,13 +79256,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -79022,12 +79305,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -79053,20 +79336,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -79083,15 +79366,15 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { @@ -79105,7 +79388,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -79118,7 +79401,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -79131,7 +79414,7 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); @@ -79140,11 +79423,11 @@ var ts; return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -79156,7 +79439,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -79165,7 +79448,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -79178,7 +79461,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -79198,17 +79481,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -79218,9 +79501,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -79229,7 +79512,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -79244,28 +79527,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -79286,7 +79569,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -79297,23 +79580,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -79361,11 +79644,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -79395,7 +79678,7 @@ var ts; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -79420,7 +79703,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -79453,7 +79736,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -79465,7 +79748,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -79480,7 +79763,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -79490,8 +79773,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -79511,7 +79794,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -79522,7 +79805,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -79540,18 +79823,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -79569,113 +79852,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -79700,19 +79983,28 @@ var ts; if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) { + checkNodeDeferred(node); + addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); + } + function checkTypeParameterDeferred(node) { + if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) { + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); var modifiers = getVarianceModifiers(typeParameter); - if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + if (modifiers) { var symbol = getSymbolOfNode(node.parent); - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); - var saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { + error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubType : markerSuperType); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperType : markerSubType); + var saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); } function checkParameter(node) { // Grammar checking @@ -79722,11 +80014,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -79737,13 +80029,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -79767,7 +80059,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -79801,13 +80093,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -79821,11 +80113,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -79834,29 +80126,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -79872,17 +80164,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -79894,18 +80186,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -79917,11 +80209,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -79932,24 +80224,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -79959,19 +80251,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -80020,15 +80312,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -80045,7 +80337,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -80093,7 +80385,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -80110,7 +80402,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -80120,9 +80412,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -80130,8 +80422,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -80163,7 +80455,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -80184,9 +80476,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -80202,7 +80494,7 @@ var ts; superCallStatement = statement; break; } - if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -80225,7 +80517,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -80243,9 +80535,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -80253,25 +80545,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -80283,7 +80575,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -80315,15 +80607,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -80339,10 +80631,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -80381,29 +80673,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -80423,15 +80715,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -80439,14 +80731,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -80495,7 +80787,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -80505,7 +80797,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -80532,8 +80824,8 @@ var ts; if (node.assertions) { var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -80543,31 +80835,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -80592,16 +80884,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -80618,8 +80910,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -80628,7 +80920,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -80657,7 +80949,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -80682,7 +80974,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -80698,8 +80990,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -80710,10 +81002,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -80757,13 +81049,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -80773,7 +81065,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -80813,15 +81105,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -80854,56 +81146,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -80939,32 +81231,32 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -80984,16 +81276,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -81003,7 +81295,7 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } @@ -81027,7 +81319,7 @@ var ts; var baseConstraint = getBaseConstraintOfType(type); // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { + if (!baseConstraint || (baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { // Nothing to do if `Awaited` doesn't exist var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); if (awaitedSymbol) { @@ -81073,7 +81365,7 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); } @@ -81190,7 +81482,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -81213,10 +81505,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -81236,7 +81528,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -81249,26 +81541,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -81290,9 +81582,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -81327,15 +81619,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -81344,13 +81636,13 @@ var ts; var commonEntityName; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -81395,15 +81687,15 @@ var ts; error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } var firstDecorator = node.decorators[0]; - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -81412,23 +81704,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -81518,9 +81810,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -81534,7 +81826,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -81550,7 +81842,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -81560,7 +81852,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -81578,7 +81870,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -81606,42 +81898,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -81652,41 +81944,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -81697,7 +81989,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -81714,7 +82006,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -81726,17 +82018,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -81773,7 +82065,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -81804,7 +82096,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -81820,10 +82112,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -81836,9 +82128,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -81857,38 +82149,38 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -81905,7 +82197,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -81923,17 +82215,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -81953,8 +82245,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -81968,8 +82260,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -81983,53 +82275,53 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -82040,7 +82332,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -82048,13 +82340,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -82072,7 +82364,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -82104,35 +82396,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -82163,23 +82455,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } if (ts.isBindingElement(node)) { - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -82189,15 +82481,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -82208,7 +82500,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -82225,7 +82517,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -82236,7 +82528,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -82250,7 +82542,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -82266,7 +82558,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (node.initializer) { @@ -82276,10 +82568,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -82287,7 +82579,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -82297,24 +82589,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -82340,7 +82632,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -82349,13 +82641,13 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) @@ -82369,7 +82661,7 @@ var ts; // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -82409,7 +82701,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -82433,7 +82725,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -82463,7 +82755,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -82474,12 +82766,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -82504,29 +82796,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -82558,7 +82850,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -82572,7 +82864,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -82585,7 +82877,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -82602,7 +82894,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -82617,14 +82909,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -82633,10 +82925,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -82653,22 +82945,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -82676,7 +82968,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -82688,7 +82980,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -82697,12 +82989,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -82710,9 +83002,9 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { - return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; @@ -82759,9 +83051,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -82831,17 +83123,17 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } return undefined; } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; @@ -82851,7 +83143,7 @@ var ts; var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; @@ -82890,20 +83182,20 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? + return use & 8 /* IterationUse.ForOfFlag */ ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { // for a sync iterable in an async context, only use the cached types if they are valid. if (iterationTypes !== noIterationTypes) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); @@ -82914,16 +83206,16 @@ var ts; } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : noIterationTypes); @@ -82989,7 +83281,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -83004,11 +83296,11 @@ var ts; function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } @@ -83088,13 +83380,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -83149,15 +83441,15 @@ var ts; if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" @@ -83263,7 +83555,7 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); @@ -83275,15 +83567,15 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync) || errorType : isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -83303,21 +83595,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -83328,7 +83620,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -83336,7 +83628,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -83357,7 +83649,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -83366,7 +83658,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -83403,7 +83695,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -83435,8 +83727,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -83448,7 +83740,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -83468,8 +83760,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -83498,9 +83790,9 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; var _loop_28 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared @@ -83520,7 +83812,7 @@ var ts; function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; var _loop_29 = function (info) { if (info === checkInfo) @@ -83561,7 +83853,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -83640,9 +83932,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -83729,7 +84021,7 @@ var ts; if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -83750,15 +84042,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -83790,18 +84082,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -83836,7 +84128,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -83886,7 +84178,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -83900,7 +84192,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -83919,12 +84211,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -83937,13 +84229,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -83954,9 +84246,9 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible @@ -83988,10 +84280,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -84007,7 +84299,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -84019,7 +84311,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -84027,11 +84319,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -84054,7 +84346,7 @@ var ts; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -84073,7 +84365,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -84087,7 +84379,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -84098,24 +84390,24 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { // either base or derived property is private - not override, skip it continue; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */ + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment continue; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -84123,12 +84415,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -84145,16 +84437,16 @@ var ts; continue; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { // method is overridden with method or property -- correct case continue; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -84220,20 +84512,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -84243,7 +84535,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -84258,7 +84550,7 @@ var ts; ts.setParent(reference, staticBlock); reference.flowNode = staticBlock.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) { + if (!(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */)) { return true; } } @@ -84273,7 +84565,7 @@ var ts; ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 32768 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -84286,7 +84578,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -84319,7 +84611,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -84331,8 +84623,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -84357,7 +84649,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -84374,7 +84666,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -84382,20 +84674,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -84405,60 +84697,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -84494,9 +84786,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -84530,7 +84822,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -84559,9 +84851,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -84592,7 +84884,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -84605,7 +84897,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -84615,7 +84907,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -84631,10 +84923,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -84644,7 +84936,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -84676,23 +84968,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -84703,12 +84995,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -84718,7 +85010,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -84729,20 +85021,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -84756,9 +85048,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -84799,39 +85091,39 @@ var ts; // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -84856,15 +85148,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -84890,11 +85182,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -84903,8 +85195,11 @@ var ts; var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration); var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!ts.isNightly()) { + grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -84937,11 +85232,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -84963,20 +85258,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -84985,7 +85280,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -85000,8 +85295,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -85009,10 +85304,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -85032,12 +85327,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -85047,7 +85342,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -85057,7 +85352,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -85105,15 +85400,15 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -85123,7 +85418,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -85135,8 +85430,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -85153,14 +85448,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -85176,10 +85471,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -85214,11 +85509,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -85264,177 +85559,177 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -85515,7 +85810,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -85527,38 +85822,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 163 /* SyntaxKind.TypeParameter */: + checkTypeParameterDeferred(node); + break; + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -85566,7 +85864,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -85578,9 +85876,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -85592,7 +85890,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -85612,13 +85910,13 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -85642,7 +85940,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -85712,14 +86010,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -85727,17 +86025,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -85745,17 +86043,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -85799,7 +86097,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -85807,25 +86105,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -85833,16 +86131,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -85870,13 +86168,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -85887,12 +86185,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -85902,7 +86200,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -85912,7 +86210,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -85922,17 +86220,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -85948,28 +86246,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -85980,13 +86278,13 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name)); if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { @@ -85998,16 +86296,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -86019,12 +86317,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -86039,7 +86337,7 @@ var ts; function resolveJSDocMemberName(name, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -86051,18 +86349,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -86076,12 +86374,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -86089,27 +86387,32 @@ var ts; return propertyDeclaration; } } - else if (ts.isMetaProperty(parent)) { - var parentType = getTypeOfNode(parent); - var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === 103 /* NewKeyword */) { + else if (ts.isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { + // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } + // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but + // we have a fake expression type made for other reasons already, whose transient `meta` + // member should more exactly be the kind of (declarationless) symbol we want. + // (See #44364 and #45031 for relevant implementation PRs) + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { + return getGlobalImportMetaExpressionType().members.get("meta"); + } + // no other meta properties are valid syntax, thus no others should have symbols + return undefined; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -86121,25 +86424,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -86148,7 +86451,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -86156,19 +86459,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -86178,14 +86481,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -86194,17 +86497,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -86235,7 +86538,7 @@ var ts; if (ts.isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { var symbol = getSymbolAtLocation(node); @@ -86245,7 +86548,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -86266,23 +86569,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -86292,7 +86595,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -86325,14 +86628,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -86342,8 +86645,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -86362,18 +86665,18 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] - : ts.singleElementArray(tryGetAliasTarget(symbol)); + : ts.singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol) { + function tryGetTarget(symbol) { var target; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -86412,13 +86715,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -86436,19 +86739,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -86471,7 +86774,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -86480,20 +86783,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -86509,9 +86812,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -86552,20 +86855,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -86573,7 +86876,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -86590,7 +86893,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -86603,9 +86906,9 @@ var ts; if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } - var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -86643,18 +86946,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); - } - function isOptionalUninitializedParameter(parameter) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86662,10 +86960,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86688,19 +86986,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -86710,7 +87008,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -86726,14 +87024,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -86752,28 +87050,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -86789,37 +87087,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -86838,7 +87136,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -86859,7 +87157,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -86967,18 +87265,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -86994,7 +87292,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -87031,7 +87329,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -87042,9 +87340,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -87091,7 +87389,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -87119,12 +87417,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -87195,7 +87493,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -87257,28 +87555,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -87292,29 +87590,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -87333,14 +87631,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -87354,69 +87652,69 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -87428,186 +87726,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ && - node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -87625,41 +87922,41 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.fail(); } @@ -87670,10 +87967,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -87702,7 +87999,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -87727,7 +88024,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -87762,7 +88059,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -87798,7 +88095,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -87827,7 +88124,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -87844,6 +88141,9 @@ var ts; return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { + if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } function checkGrammarClassDeclarationHeritageClauses(node) { @@ -87852,7 +88152,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -87865,7 +88165,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -87881,14 +88181,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -87899,21 +88199,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -87931,7 +88231,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -87942,23 +88242,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */) { + if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -87973,25 +88273,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -88006,14 +88306,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -88033,7 +88333,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -88043,7 +88343,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -88078,16 +88378,32 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -88096,8 +88412,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -88108,12 +88424,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -88128,20 +88444,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -88151,22 +88467,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -88174,11 +88490,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -88200,17 +88516,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -88220,26 +88536,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -88247,9 +88563,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -88262,10 +88578,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -88283,7 +88599,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -88291,17 +88607,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -88312,11 +88628,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -88324,8 +88640,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -88340,13 +88656,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -88370,18 +88686,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -88389,7 +88705,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -88406,8 +88722,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -88419,7 +88735,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88428,7 +88744,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -88441,7 +88757,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -88458,8 +88774,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -88486,15 +88802,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -88512,12 +88828,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -88575,7 +88891,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -88585,11 +88901,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -88605,11 +88921,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88631,14 +88947,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -88646,7 +88962,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -88655,10 +88971,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -88669,7 +88985,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -88686,19 +89002,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -88711,7 +89027,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -88732,7 +89048,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -88766,7 +89082,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -88774,7 +89090,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -88782,10 +89098,10 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } var nodeArguments = node.arguments; if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) { @@ -88793,7 +89109,7 @@ var ts; checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { var assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } if (nodeArguments.length === 0 || nodeArguments.length > 2) { @@ -88809,14 +89125,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -88825,35 +89141,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -88865,9 +89181,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -88875,7 +89191,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -88897,14 +89213,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -88924,17 +89240,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -89048,7 +89364,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -89056,11 +89372,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -89107,8 +89423,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -89154,446 +89470,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -89818,7 +90134,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -89828,7 +90144,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -89971,14 +90287,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -90055,8 +90371,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -90106,19 +90422,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -90186,7 +90502,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -90279,12 +90595,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -90335,7 +90651,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -90348,13 +90664,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -90385,23 +90701,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90419,9 +90735,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90502,7 +90818,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -90517,27 +90833,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -90599,7 +90915,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -90884,9 +91200,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -90927,14 +91243,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -90949,10 +91265,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -91155,7 +91471,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -91211,8 +91527,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -91238,14 +91554,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -91296,17 +91612,17 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -91317,7 +91633,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -91340,7 +91656,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -91360,10 +91676,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -91376,7 +91692,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -91384,13 +91700,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -91410,15 +91726,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -91438,30 +91754,30 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -91472,80 +91788,80 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. // falls through - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.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 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91555,7 +91871,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91565,35 +91881,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -91603,40 +91919,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -91650,28 +91966,28 @@ var ts; return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -91680,16 +91996,16 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return ts.visitEachChild(node, visitor, context); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); - var classStatement = facts & 2 /* HasConstructorDecorators */ + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var classStatement = facts & 2 /* ClassFacts.HasConstructorDecorators */ ? createClassDeclarationHeadWithDecorators(node, name) : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; @@ -91697,7 +92013,7 @@ var ts; addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -91709,20 +92025,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -91738,21 +92054,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -91768,7 +92084,7 @@ var ts; // ${members} // } // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : undefined; var classDeclaration = factory.createClassDeclaration( @@ -91777,8 +92093,8 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); @@ -91879,7 +92195,7 @@ var ts; var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -91897,7 +92213,7 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); @@ -92030,12 +92346,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92186,9 +92502,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -92198,7 +92514,7 @@ var ts; : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); ts.setTextRange(helper, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); return helper; } /** @@ -92226,12 +92542,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); return expression; } @@ -92257,7 +92573,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -92294,13 +92610,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); @@ -92316,10 +92632,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -92329,7 +92645,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -92340,12 +92656,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -92362,15 +92678,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -92407,7 +92723,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -92452,83 +92768,83 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return factory.createVoidZero(); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return serializeTypeNode(node.type); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return factory.createIdentifier("Array"); - case 177 /* TypePredicate */: - case 133 /* BooleanKeyword */: + case 177 /* SyntaxKind.TypePredicate */: + case 133 /* SyntaxKind.BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: switch (node.literal.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: - case 8 /* NumericLiteral */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 8 /* SyntaxKind.NumericLiteral */: return factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 151 /* SymbolKeyword */: - return languageVersion < 2 /* ES2015 */ + case 151 /* SyntaxKind.SymbolKeyword */: + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return serializeTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -92541,13 +92857,13 @@ var ts; var serializedUnion; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -92607,7 +92923,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES2015 */ + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -92629,12 +92945,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -92650,14 +92966,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -92685,7 +93001,7 @@ var ts; * available. */ function getGlobalBigIntNameWithFallback() { - return languageVersion < 99 /* ESNext */ + return languageVersion < 99 /* ScriptTarget.ESNext */ ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), /*questionToken*/ undefined, factory.createIdentifier("BigInt"), /*colonToken*/ undefined, factory.createIdentifier("Object")) @@ -92748,7 +93064,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -92776,7 +93092,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { return undefined; } var updated = factory.updatePropertyDeclaration(node, @@ -92807,11 +93123,11 @@ var ts; } var statements = []; resumeLexicalEnvironment(); - var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); + var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); } // Transform parameters into property assignments. Transforms this: // @@ -92830,12 +93146,12 @@ var ts; if (superStatementIndex >= 0) { ts.addRange(statements, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor + // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = ts.addRange(parameterPropertyAssignments, statements); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - // Add remaining statements from the body, skipping the super() call if it was found - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1)); + // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -92855,10 +93171,10 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node) { @@ -92885,7 +93201,7 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { @@ -92961,7 +93277,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -92981,7 +93297,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -92999,7 +93315,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93076,7 +93392,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93084,7 +93400,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93092,7 +93408,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93158,7 +93474,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93246,12 +93562,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93276,7 +93592,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93286,7 +93602,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93307,7 +93623,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93315,7 +93631,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93323,7 +93639,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93376,7 +93692,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93423,13 +93739,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93452,8 +93768,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*decorators*/ undefined, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) @@ -93477,14 +93793,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93525,8 +93841,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93586,7 +93902,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -93599,7 +93915,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -93620,7 +93936,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -93628,7 +93944,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -93637,7 +93953,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -93646,7 +93962,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Creates a statement for the provided expression. This is used in calls to `map`. @@ -93691,7 +94007,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -93708,37 +94024,37 @@ var ts; : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* TypeScriptSubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -93753,11 +94069,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -93771,7 +94087,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -93780,7 +94096,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -93797,11 +94113,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -93812,8 +94128,8 @@ var ts; || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -93839,9 +94155,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -93867,7 +94183,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -93930,13 +94246,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -93962,7 +94278,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -93970,50 +94286,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 8388608 /* ContainsClassFields */) { + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 8388608 /* ContainsClassFields */ || - node.transformFlags & 33554432 /* ContainsLexicalSuper */ && + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94032,17 +94348,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94072,7 +94388,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94088,19 +94404,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94149,10 +94465,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94214,11 +94530,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94237,7 +94553,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94256,7 +94572,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94270,7 +94586,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var info = void 0; if (info = accessPrivateIdentifier(node.operand.name)) { @@ -94279,7 +94595,7 @@ var ts; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94302,7 +94618,7 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { var operand = visitInvalidSuperProperty(node.operand); return ts.isPrefixUnaryExpression(node) ? factory.updatePrefixUnaryExpression(node, operand) : @@ -94418,7 +94734,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94445,7 +94761,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94487,7 +94803,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94502,12 +94818,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94547,28 +94863,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94576,8 +94892,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94590,19 +94906,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -94631,7 +94947,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94641,19 +94957,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -94682,12 +94998,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -94742,13 +95058,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -94781,7 +95097,7 @@ var ts; } resumeLexicalEnvironment(); var needsSyntheticConstructor = !constructor && isDerivedClass; - var indexOfFirstStatementAfterSuper = 0; + var indexOfFirstStatementAfterSuperAndPrologue = 0; var prologueStatementCount = 0; var superStatementIndex = -1; var statements = []; @@ -94790,8 +95106,11 @@ var ts; superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; } } if (needsSyntheticConstructor) { @@ -94827,22 +95146,20 @@ var ts; } } if (parameterPropertyDeclarationCount > 0) { - var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); // If there was a super() call found, add parameter properties immediately after it if (superStatementIndex >= 0) { ts.addRange(statements, parameterProperties); } - // If a synthetic super() call was added, add them just after it - else if (needsSyntheticConstructor) { - statements = __spreadArray(__spreadArray([ - statements[0] - ], parameterProperties, true), statements.slice(1), true); - } - // Since there wasn't a super() call, add them to the top of the constructor else { - statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true); + // Add add parameter properties to the top of the constructor after the prologue + var superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) + superAndPrologueStatementCount++; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true); } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -94852,7 +95169,7 @@ var ts; addPropertyOrClassStaticBlockStatements(statements, properties, receiver); // Add existing statements after the initial prologues and super call if (constructor) { - ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), @@ -94937,7 +95254,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -94956,7 +95273,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -94976,7 +95293,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -94995,32 +95312,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95059,13 +95376,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95075,10 +95392,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95088,7 +95405,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95109,24 +95426,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95139,8 +95456,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95173,7 +95490,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95193,7 +95510,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95226,7 +95543,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95236,7 +95553,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95245,12 +95562,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95261,12 +95578,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95282,7 +95599,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95294,7 +95611,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95305,12 +95622,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95321,12 +95638,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95343,9 +95660,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95387,9 +95704,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95403,7 +95720,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95443,7 +95760,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95562,8 +95879,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -95575,10 +95892,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -95594,39 +95911,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -95634,27 +95951,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -95737,7 +96054,7 @@ var ts; /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95753,7 +96070,7 @@ var ts; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95768,7 +96085,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95783,7 +96100,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95804,7 +96121,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -95858,9 +96175,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -95886,7 +96203,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -95899,10 +96216,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -95946,21 +96263,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -95973,8 +96290,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96001,30 +96318,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96044,19 +96361,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -96066,7 +96383,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -96076,7 +96393,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -96091,20 +96408,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -96174,7 +96491,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -96206,7 +96523,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -96228,88 +96545,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -96323,15 +96640,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -96343,7 +96660,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -96352,7 +96669,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -96363,7 +96680,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -96386,7 +96703,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -96413,9 +96730,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -96436,10 +96753,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -96467,10 +96784,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -96482,7 +96799,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -96508,8 +96825,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -96526,8 +96843,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -96555,7 +96872,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -96575,10 +96892,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -96597,18 +96914,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -96616,15 +96933,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -96640,7 +96957,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -96658,7 +96975,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -96704,13 +97021,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateMethodDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96723,13 +97040,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateFunctionDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96753,13 +97070,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96776,13 +97093,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -96793,10 +97110,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -96835,11 +97152,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96848,7 +97165,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96864,32 +97181,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96897,21 +97214,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -96924,8 +97241,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96952,30 +97269,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96995,14 +97312,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -97027,11 +97344,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -97059,29 +97376,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97123,7 +97440,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -97146,10 +97463,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -97158,7 +97475,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -97168,8 +97485,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -97179,17 +97496,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -97206,7 +97523,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -97240,11 +97557,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -97294,7 +97611,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -97318,12 +97635,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -97349,7 +97666,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -97371,7 +97688,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -97388,7 +97705,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -97404,7 +97721,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -97413,13 +97730,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97427,15 +97744,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -97504,7 +97821,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -97569,7 +97886,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -97609,14 +97926,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - else if (node.kind === 10 /* StringLiteral */) { + else if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 288 /* JsxExpression */) { + else if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -97710,7 +98027,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -98013,11 +98330,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98025,9 +98342,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98217,7 +98534,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -98227,7 +98544,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -98238,15 +98555,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -98261,11 +98578,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -98277,9 +98594,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -98287,115 +98604,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -98406,14 +98723,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -98421,17 +98738,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -98447,11 +98764,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -98478,30 +98795,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -98510,15 +98827,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -98551,18 +98868,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -98619,25 +98936,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -98655,19 +98972,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98693,7 +99010,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -98704,10 +99021,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -98741,7 +99058,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98756,7 +99073,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -98800,7 +99117,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -98810,7 +99127,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -98833,7 +99150,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -98872,7 +99189,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -98893,7 +99210,7 @@ var ts; // ``` insertCaptureThisForNodeIfNeeded(prologue, constructor); } - var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), + var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), /*location*/ constructor.body.statements), /*multiLine*/ true); ts.setTextRange(body, constructor.body); @@ -98922,11 +99239,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -98934,7 +99251,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -98943,10 +99260,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -99035,11 +99352,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -99057,11 +99374,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -99092,10 +99409,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -99105,7 +99422,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -99117,13 +99434,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -99136,7 +99453,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -99150,7 +99467,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -99158,38 +99475,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -99197,11 +99514,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -99220,21 +99537,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -99273,7 +99590,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -99281,7 +99598,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -99295,7 +99612,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -99311,20 +99628,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -99332,7 +99649,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -99355,12 +99672,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -99369,9 +99686,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -99381,17 +99698,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -99406,13 +99723,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, @@ -99430,14 +99747,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -99480,7 +99797,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -99499,7 +99816,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -99520,10 +99837,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -99533,11 +99850,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99568,9 +99885,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -99598,12 +99915,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -99612,10 +99929,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -99632,7 +99949,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99641,11 +99958,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -99654,7 +99971,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 262144 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -99720,18 +100037,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -99758,16 +100075,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -99787,50 +100104,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -99878,7 +100195,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -99910,18 +100227,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -99937,33 +100254,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -99978,9 +100295,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 524288 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 524288 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -99993,7 +100310,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -100005,7 +100322,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -100021,7 +100338,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -100032,7 +100349,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -100052,7 +100369,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -100096,11 +100413,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -100125,11 +100442,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -100138,7 +100455,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -100251,15 +100568,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -100285,12 +100602,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -100352,7 +100669,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -100361,17 +100678,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -100391,18 +100708,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -100415,7 +100732,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -100424,27 +100741,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -100452,7 +100769,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -100511,19 +100828,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -100545,20 +100862,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -100613,14 +100930,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -100629,7 +100946,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -100648,7 +100965,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -100661,17 +100978,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -100714,11 +101031,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -100791,7 +101108,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -100848,15 +101165,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -100870,7 +101187,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -100882,12 +101199,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -100976,13 +101293,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -100998,12 +101315,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -101011,7 +101328,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -101041,7 +101358,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -101076,15 +101393,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -101096,13 +101413,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -101112,9 +101429,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -101122,16 +101439,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -101142,7 +101459,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -101156,7 +101473,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -101172,10 +101489,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -101188,9 +101505,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -101201,7 +101518,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -101238,9 +101555,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -101257,19 +101574,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -101292,18 +101609,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -101322,9 +101639,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -101384,7 +101701,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -101564,11 +101881,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -101622,7 +101939,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -101645,7 +101962,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -101659,13 +101976,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -101678,30 +101995,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -101716,23 +102033,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -101745,9 +102062,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -101906,13 +102223,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101937,9 +102254,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -101955,7 +102272,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -101967,7 +102284,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -101999,7 +102316,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -102033,13 +102350,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -102056,12 +102373,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -102106,7 +102423,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -102172,7 +102489,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -102361,35 +102678,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -102819,7 +103136,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -102832,7 +103149,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -102964,7 +103281,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -102977,7 +103294,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -103008,7 +103325,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -103054,7 +103371,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -103068,7 +103385,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -103097,7 +103414,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -103107,7 +103424,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -103119,8 +103436,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -103133,7 +103450,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -103146,18 +103463,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -103167,24 +103484,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -103192,7 +103509,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -103202,7 +103519,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -103219,7 +103536,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -103231,7 +103548,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103245,7 +103562,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -103258,7 +103575,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -103268,7 +103585,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103277,7 +103594,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -103286,14 +103603,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -103305,8 +103622,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -103314,7 +103631,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -103322,7 +103639,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -103419,7 +103736,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -103431,7 +103748,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -103443,8 +103760,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -103457,7 +103774,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -103466,7 +103783,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -103480,7 +103797,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -103489,7 +103806,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -103500,7 +103817,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -103511,7 +103828,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -103520,7 +103837,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -103529,7 +103846,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -103538,7 +103855,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -103547,13 +103864,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -103597,7 +103914,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -103770,8 +104087,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -103781,18 +104098,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -103816,33 +104133,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -103892,8 +104209,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -103904,9 +104221,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -103917,9 +104234,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -103930,9 +104247,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -103943,8 +104260,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -103955,9 +104272,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -103965,7 +104282,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -103992,12 +104309,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -104013,7 +104330,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 4194304 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -104149,7 +104466,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -104234,7 +104551,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -104303,13 +104620,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -104325,23 +104642,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -104350,30 +104667,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4194304 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -104389,24 +104706,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -104432,7 +104749,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -104458,7 +104775,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -104501,7 +104818,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -104528,7 +104845,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -104564,7 +104881,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -104582,7 +104899,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -104603,7 +104920,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -104623,13 +104940,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -104638,7 +104955,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -104685,7 +105002,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -104699,7 +105016,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -104733,7 +105050,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -104743,11 +105060,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -104788,12 +105105,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -104844,7 +105161,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), @@ -104872,7 +105189,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); @@ -104899,7 +105216,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -104957,7 +105274,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -104972,7 +105289,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -104994,7 +105311,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -105006,7 +105323,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -105049,10 +105366,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -105135,8 +105452,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -105181,7 +105498,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -105194,7 +105511,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -105209,7 +105526,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -105221,7 +105538,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -105248,8 +105565,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -105265,7 +105582,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -105290,7 +105607,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -105325,13 +105642,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -105340,9 +105657,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105351,9 +105668,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105366,16 +105683,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -105464,11 +105781,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -105488,7 +105805,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -105535,7 +105852,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -105657,8 +105974,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 1048576 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -105692,7 +106009,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -105758,7 +106075,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -105782,19 +106099,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -105853,13 +106170,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -105935,7 +106252,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -105988,7 +106305,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -106038,9 +106355,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -106051,7 +106368,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -106103,9 +106420,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -106116,7 +106433,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106165,10 +106482,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -106262,8 +106579,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -106323,7 +106640,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106335,7 +106652,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -106348,43 +106665,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -106566,30 +106883,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 4194304 /* TransformFlags.ContainsDynamicImport */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -106639,7 +106956,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -106669,7 +106986,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -106685,7 +107002,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -106730,8 +107047,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106747,7 +107064,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -106782,10 +107099,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -106797,7 +107114,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -106832,11 +107149,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -106848,7 +107165,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -106926,7 +107243,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -106969,8 +107286,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -107009,14 +107326,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -107034,7 +107351,7 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause( @@ -107042,16 +107359,16 @@ var ts; /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -107072,12 +107389,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); @@ -107145,7 +107462,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -107154,7 +107471,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -107177,8 +107494,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -107225,7 +107542,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -107280,14 +107597,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107309,14 +107626,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -107340,7 +107657,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -107358,31 +107675,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107405,7 +107722,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -107422,14 +107739,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -107444,36 +107761,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -107485,9 +107802,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -107510,40 +107827,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -107554,61 +107871,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -107625,7 +107942,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -107674,7 +107991,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -107693,13 +108010,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -107758,7 +108075,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -107767,7 +108084,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -107803,7 +108120,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -107874,10 +108191,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -107900,14 +108217,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -108044,11 +108361,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -108056,7 +108373,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -108069,7 +108386,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = factory.updateParameterDeclaration(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -108086,7 +108403,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -108094,19 +108411,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -108114,12 +108431,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -108130,28 +108447,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -108178,7 +108495,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -108215,7 +108532,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -108241,7 +108558,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -108261,7 +108578,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -108279,34 +108596,44 @@ var ts; if (!decl.importClause) { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // The `importClause` visibility corresponds to the default's visibility. var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, - /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } // Named imports (optionally with visible default) var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Augmentation of export depends on import if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, - /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Nothing visible } + function getResolutionModeOverrideForClauseInNightly(assertClause) { + var mode = ts.getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!ts.isNightly()) { + context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } function transformAndReplaceLatePaintedStatements(statements) { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. @@ -108325,7 +108652,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -108383,10 +108710,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -108404,29 +108731,29 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -108436,48 +108763,48 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateSetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { + case 176 /* SyntaxKind.IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -108485,13 +108812,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -108503,22 +108830,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -108541,7 +108868,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -108551,7 +108878,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -108561,17 +108888,17 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -108579,7 +108906,9 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); + preserveJsDoc(statement, input); + ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -108590,22 +108919,26 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { + if (lateMarkedStatements) { + while (ts.orderedRemoveItem(lateMarkedStatements, input)) + ; + } if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -108626,14 +108959,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -108642,7 +108975,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -108661,10 +108994,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -108675,11 +109008,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, @@ -108700,17 +109033,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -108746,7 +109079,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -108756,10 +109089,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -108801,26 +109134,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -108831,10 +109164,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -108845,7 +109178,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -108853,7 +109186,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -108876,7 +109209,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -108924,12 +109257,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 125951 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 125951 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -108949,13 +109282,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -108965,22 +109298,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 125951 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 125951 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -108989,52 +109322,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -109052,7 +109385,7 @@ var ts; return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return ts.transformNodeModule; default: @@ -109091,35 +109424,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -109173,11 +109506,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -109190,7 +109523,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -109220,13 +109553,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -109250,17 +109583,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -109278,15 +109611,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -109296,23 +109629,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -109322,7 +109655,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -109338,26 +109671,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -109369,9 +109702,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -109384,8 +109717,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -109399,19 +109732,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -109420,8 +109753,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -109433,7 +109766,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -109476,8 +109809,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -109486,12 +109819,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -109505,8 +109838,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -109517,14 +109850,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -109539,7 +109872,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -109578,7 +109911,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -109644,7 +109977,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -109652,7 +109985,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -109661,7 +109994,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -109669,7 +110002,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -109683,11 +110016,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -109703,9 +110036,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -109730,20 +110063,20 @@ var ts; addOutput(buildInfoPath); } function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) { - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -109775,7 +110108,7 @@ var ts; /*@internal*/ function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; /*@internal*/ @@ -109812,17 +110145,17 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) continue; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -109831,7 +110164,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -109869,13 +110202,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -110010,7 +110343,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SyntaxKind.SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -110021,7 +110354,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -110033,8 +110366,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -110046,6 +110379,7 @@ var ts; else { printer.writeFile(sourceFile, writer, sourceMapGenerator); } + var sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -110057,7 +110391,8 @@ var ts; if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + sourceMapUrlPos = writer.getTextPos(); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { @@ -110069,13 +110404,13 @@ var ts; writer.writeLine(); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -110106,7 +110441,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -110199,8 +110534,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -110286,7 +110621,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -110338,7 +110673,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -110378,20 +110713,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -110447,11 +110782,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -110486,7 +110821,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -110497,7 +110832,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -110507,7 +110842,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -110534,7 +110869,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -110544,7 +110879,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -110583,7 +110918,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -110591,30 +110926,30 @@ var ts; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); + return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile))); } function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -110623,7 +110958,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -110639,12 +110974,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -110652,17 +110987,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -110672,7 +111007,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -110698,346 +111033,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -111049,101 +111384,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -111151,7 +111486,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -111161,7 +111496,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -111191,7 +111526,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -111233,7 +111568,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -111261,7 +111596,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -111291,9 +111626,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -111312,25 +111647,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -111338,7 +111673,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -111353,7 +111688,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -111390,7 +111725,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -111458,7 +111793,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -111568,8 +111903,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -111582,16 +111917,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -111600,10 +111935,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -111636,7 +111971,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -111650,7 +111985,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -111659,13 +111994,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -111675,7 +112010,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -111683,14 +112018,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -111698,7 +112033,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -111717,7 +112052,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -111733,12 +112068,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -111756,29 +112091,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -111804,7 +112139,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -111817,12 +112152,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111835,17 +112170,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111867,12 +112202,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -111891,22 +112226,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -111931,9 +112266,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -111974,12 +112309,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -112010,11 +112345,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -112025,7 +112360,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -112047,15 +112382,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -112098,10 +112433,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -112122,21 +112457,21 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) - if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -112146,14 +112481,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -112169,45 +112504,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -112216,12 +112551,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -112244,13 +112579,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -112290,40 +112625,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -112332,13 +112667,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -112354,7 +112689,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -112372,7 +112707,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -112409,23 +112744,23 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { return false; } - if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { + if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) { + if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -112440,14 +112775,9 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -112460,11 +112790,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -112479,15 +112809,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -112500,10 +112830,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -112526,13 +112856,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -112554,27 +112884,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112583,12 +112913,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -112599,20 +112929,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112623,37 +112953,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -112663,10 +112993,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -112674,26 +113004,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112705,7 +113035,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -112716,7 +113046,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -112735,7 +113065,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -112748,7 +113078,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -112777,7 +113107,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -112808,17 +113138,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112829,30 +113159,31 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { var emitAsSingleStatement = statements.length === 1 && ( // treat synthesized nodes as located on the same line for emit purposes - ts.nodeIsSynthesized(parentNode) || + !currentSourceFile || + ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -112860,15 +113191,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -112888,7 +113219,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -112905,7 +113236,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -112936,12 +113267,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -112975,13 +113306,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -113000,7 +113331,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -113018,14 +113349,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -113073,16 +113404,14 @@ var ts; function emitSourceFile(node) { writeLine(); var statements = node.statements; - if (emitBodyWithDetachedComments) { - // Emit detached comment if there are no prologue directives or if the first node is synthesized. - // The synthesized node will have no leading comment so some comments may be missed. - var shouldEmitDetachedComment = statements.length === 0 || - !ts.isPrologueDirective(statements[0]) || - ts.nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -113108,21 +113437,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -113130,28 +113459,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { var directive = types_24[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -113162,22 +113491,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -113198,7 +113527,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -113219,7 +113548,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -113312,7 +113641,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 262656 /* Modifiers */); + emitList(node, modifiers, 262656 /* ListFormat.Modifiers */); writeSpace(); } } @@ -113326,7 +113655,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -113356,7 +113685,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -113364,7 +113693,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -113373,19 +113702,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -113406,32 +113735,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -113447,11 +113776,11 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -113460,7 +113789,7 @@ var ts; } return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -113471,28 +113800,28 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } else { ts.Debug.type(children); // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -113503,7 +113832,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -113515,7 +113844,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -113525,14 +113854,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -113555,11 +113884,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (hasTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -113571,11 +113900,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -113584,14 +113913,14 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -113676,7 +114005,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -113726,13 +114055,13 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -113752,11 +114081,11 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild_1.kind === 11 /* JsxText */) { + if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { @@ -113769,18 +114098,18 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); } @@ -113794,7 +114123,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -113803,18 +114132,18 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -113825,7 +114154,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -113854,14 +114183,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -113870,14 +114199,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -113887,7 +114216,7 @@ var ts; if (ts.getStartsOnNewLine(node2)) { return 1; } - if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); } @@ -113897,10 +114226,10 @@ var ts; } function isEmptyBlock(block) { return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -113909,41 +114238,48 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return generateName(node); } - else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { - return ts.idText(node); - } - else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (ts.isStringLiteral(node) && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + var sourceFile = currentSourceFile; // const needed for control flow + var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node); + if (ts.isMemberName(node)) { + if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) { + return ts.idText(node); + } } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + else { + ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary + if (!canUseSourceFile) { + return node.text; + } + } + return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -113954,7 +114290,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -113970,84 +114306,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -114056,12 +114392,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -114080,7 +114416,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -114119,7 +114455,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -114133,7 +114469,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -114143,12 +114479,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -114180,7 +114516,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -114234,48 +114570,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -114291,7 +114627,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -114302,7 +114638,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -114315,7 +114651,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -114323,7 +114659,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -114337,25 +114673,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -114365,7 +114701,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -114374,18 +114710,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -114403,25 +114739,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -114497,7 +114833,7 @@ var ts; return true; } function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); @@ -114510,7 +114846,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -114524,7 +114860,7 @@ var ts; forEachTrailingCommentToEmit(pos, emitTrailingComment); } function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { @@ -114546,15 +114882,19 @@ var ts; exitComment(); } function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); @@ -114587,6 +114927,8 @@ var ts; return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { + if (!currentSourceFile) + return; // get the leading comments from detachedPos var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { @@ -114598,7 +114940,7 @@ var ts; ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -114609,7 +114951,7 @@ var ts; } } function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); @@ -114621,7 +114963,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps function getParsedSourceMap(node) { @@ -114631,7 +114973,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -114649,12 +114991,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -114664,11 +115006,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -114721,17 +115063,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -114762,23 +115104,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -115144,7 +115486,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -115153,11 +115495,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -115167,7 +115509,7 @@ var ts; if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored - if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileOrDirectoryPath)) { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; @@ -115179,9 +115521,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -115214,7 +115556,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -115249,36 +115591,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -115288,16 +115630,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -115509,7 +115851,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -115520,7 +115862,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -115536,7 +115878,11 @@ var ts; return newValue; }; if (originalWriteFile) { - host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) { + host.writeFile = function (fileName, data) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); @@ -115550,7 +115896,7 @@ var ts; sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } // directoryExists @@ -115604,12 +115950,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -115697,9 +116043,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -115713,7 +116059,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -115776,7 +116122,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115882,7 +116228,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -116062,11 +116408,11 @@ var ts; */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { - case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; @@ -116116,7 +116462,6 @@ var ts; ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -116222,7 +116567,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -116303,16 +116648,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -116340,7 +116685,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -116349,19 +116694,19 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId }); } ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -116483,14 +116828,15 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, + writeFile: writeFile, }; onProgramCreateComplete(); // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -116502,17 +116848,52 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; + function addResolutionDiagnostics(list) { + if (!list) + return; + for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { + var elem = list_3[_i]; + programDiagnostics.add(elem); + } + } + function pullDiagnosticsFromCache(names, containingFile) { + var _a; + if (!moduleResolutionCache) + return; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + var containingDir = ts.getDirectoryPath(containingFileName); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var n = names_4[_i]; + // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less + var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + var name = typeof n === "string" ? n : n.fileName; + i++; + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + if (ts.isExternalModuleNameRelative(name)) + continue; + var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -116521,7 +116902,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -116531,7 +116912,7 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) + if (redirect || !ts.isDeclarationFileName(file.originalFileName)) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case @@ -116603,7 +116984,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -116758,22 +117139,22 @@ var ts; function tryReuseStructureFromOldProgram() { var _a; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -116781,12 +117162,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -116801,7 +117182,7 @@ var ts; ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; @@ -116810,7 +117191,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -116818,7 +117199,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -116835,9 +117216,9 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } @@ -116845,49 +117226,49 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); @@ -116908,7 +117289,7 @@ var ts; // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -116919,18 +117300,18 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping @@ -116961,7 +117342,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -116980,7 +117361,7 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, getSymlinkCache: getSymlinkCache, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + writeFile: writeFileCallback || writeFile, isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { @@ -117000,9 +117381,12 @@ var ts; getFileIncludeReasons: program.getFileIncludeReasons, }; } + function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -117054,7 +117438,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -117174,7 +117558,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -117182,8 +117566,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -117262,22 +117646,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -117285,65 +117669,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -117352,53 +117736,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 124 /* StaticKeyword */) { + if (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -117411,27 +117795,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -117501,20 +117885,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -117545,7 +117929,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -117567,7 +117951,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -117622,7 +118006,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -117737,7 +118121,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -117922,7 +118306,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -117932,7 +118316,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -117965,13 +118349,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -118010,14 +118394,14 @@ var ts; var fileName = ts.toFileNameLowerCase(ref.fileName); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); var mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { - programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { + programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, }); } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -118076,7 +118460,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -118096,7 +118480,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -118143,7 +118527,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -118204,7 +118588,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -118344,19 +118728,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -118373,7 +118757,7 @@ var ts; } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && - ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -118395,7 +118779,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -118417,7 +118801,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -118431,7 +118815,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -118439,12 +118823,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -118523,7 +118907,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -118762,7 +119146,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -118772,16 +119156,16 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -118882,12 +119266,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -118940,7 +119324,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -119036,17 +119420,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -119065,7 +119449,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -119080,7 +119464,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -119105,13 +119489,9 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - var manyToManyPathMapCount = 0; function createManyToManyPathMap() { function create(forward, reverse, deleted) { - var version = 0; var map = { - id: manyToManyPathMapCount++, - version: function () { return version; }, clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, @@ -119127,30 +119507,29 @@ var ts; } set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); forward.delete(k); - version++; return true; }, set: function (k, vSet) { - var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + deleted === null || deleted === void 0 ? void 0 : deleted.delete(k); var existingVSet = forward.get(k); forward.set(k, vSet); existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(function (v) { if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } return map; }, + clear: function () { + forward.clear(); + reverse.clear(); + deleted === null || deleted === void 0 ? void 0 : deleted.clear(); + } }; return map; } @@ -119165,11 +119544,10 @@ var ts; } set.add(v); } - function deleteFromMultimap(map, k, v, removeEmpty) { - if (removeEmpty === void 0) { removeEmpty = true; } + function deleteFromMultimap(map, k, v) { var set = map.get(k); if (set === null || set === void 0 ? void 0 : set.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -119398,7 +119776,7 @@ var ts; /*forceDtsEmit*/ true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -119448,6 +119826,7 @@ var ts; } } } + BuilderState.updateExportedModules = updateExportedModules; /** * Updates the exported modules from cache into state's exported modules map * This should be called whenever it is safe to commit the state of the builder @@ -119456,20 +119835,6 @@ var ts; var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - var cacheId = exportedModulesMapCache.id; - var cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - // If this is the same cache at the same version as last time this BuilderState - // was updated, there's no need to update again - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } @@ -119718,7 +120083,7 @@ var ts; } else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -119803,7 +120168,8 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash) { + function getNextAffectedFile(state, cancellationToken, computeHash, host) { + var _a; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -119814,7 +120180,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -119826,6 +120192,7 @@ var ts; ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); state.currentAffectedFilesSignatures.clear(); ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); state.affectedFiles = undefined; } // Get next changed file @@ -119855,6 +120222,11 @@ var ts; state.seenAffectedFiles = new ts.Set(); } } + function clearAffectedFilesPendingEmit(state) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } /** * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet */ @@ -119874,49 +120246,48 @@ var ts; } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } + function removeDiagnosticsOfLibraryFiles(state) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var program_1 = ts.Debug.checkDefined(state.program); + var options_2 = program_1.getCompilerOptions(); + ts.forEach(program_1.getSourceFiles(), function (f) { + return program_1.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2, program_1) && + removeSemanticDiagnosticsOf(state, f.resolvedPath); + }); + } + } /** * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.checkDefined(state.program); - var options_2 = program_1.getCompilerOptions(); - ts.forEach(program_1.getSourceFiles(), function (f) { - return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2, program_1) && - removeSemanticDiagnosticsOf(state, f.resolvedPath); - }); - } + removeDiagnosticsOfLibraryFiles(state); // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } - else { - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); - } - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); - } + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) + return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -119927,11 +120298,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, - /* useFileVersionAsSignature */ true); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -119953,16 +120323,41 @@ var ts; var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } + function forEachKeyOfExportedModulesMap(state, filePath, fn) { + // Go through exported modules from cache first + var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); + var result = keys && ts.forEachKey(keys, fn); + if (result) + return result; + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + keys = state.exportedModulesMap.getKeys(filePath); + return keys && ts.forEachKey(keys, function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? + fn(exportedFromPath) : + undefined; + }); + } + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + var _a; + if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) + return false; + // Every file needs to be handled + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + removeDiagnosticsOfLibraryFiles(state); + return true; + } /** - * Iterate on referencing modules that export entities from affected file + * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - var _a, _b; + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; - } if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself @@ -119975,7 +120370,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -119987,56 +120384,38 @@ var ts; var seenFileAndExportsOfFile = new ts.Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + return true; + var references = state.referencedMap.getKeys(exportedFromPath); + return references && ts.forEachKey(references, function (filePath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + }); }); } /** - * Iterate on files referencing referencedPath + * handle dts and semantic diagnostics on file and iterate on anything that exports this file + * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { var _a; - (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { - return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); - }); - } - /** - * fn on file and iterate on anything that exports this file - */ - function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { - var _a, _b, _c; - if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - fn(state, filePath); + if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) + return undefined; + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) - (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file - fn(state, referencingFilePath); - } // Dont add to seen since this is not yet done with the export removal - ); + handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal + state, referencingFilePath, cancellationToken, computeHash, host); + }); + return undefined; } /** * This is called after completing operation on the next affected file. @@ -120125,13 +120504,18 @@ var ts; var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + // If file version is same as signature, dont serialize signature + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // If file info only contains version and signature and both are same we can just write string value.version : - actualSignature !== undefined ? + actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo signature === undefined ? + // If we havent computed signature, use fileInfo as is value : + // Serialize fileInfo with new updated signature { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // Signature of the FileInfo is undefined, serialize it as false { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; @@ -120376,8 +120760,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -120390,7 +120774,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -120407,7 +120791,43 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + } + function getWriteFileUpdatingSignatureCallback(writeFile) { + return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + var _a; + if (ts.isDeclarationFileName(fileName)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; + if (signature === file.version) { + var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { // Update it + if (host.storeFilesChangingSignatureDuringEmit) + (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); + if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { + state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) + ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) + writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else + state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; } /** * Emits the JavaScript and declaration files. @@ -120421,56 +120841,52 @@ var ts; * in that order would be used to write the files */ function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var restorePendingEmitOnHandlingNoEmitSuccess = false; - var savedAffectedFilesPendingEmit; - var savedAffectedFilesPendingEmitKind; - var savedAffectedFilesPendingEmitIndex; - // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors - // This ensures pending files to emit is updated in tsbuildinfo - // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit) - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !ts.outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } + var _a; if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } // Emit only affected files if using builder for emit - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - // Emit and report any errors we ran into. - var sourceMaps = []; - var emitSkipped = false; - var diagnostics = void 0; - var emittedFiles = []; - var affectedEmitResult = void 0; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + // Emit and report any errors we ran into. + var sourceMaps = []; + var emitSkipped = false; + var diagnostics = void 0; + var emittedFiles = []; + var affectedEmitResult = void 0; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped: emitSkipped, + diagnostics: diagnostics || ts.emptyArray, + emittedFiles: emittedFiles, + sourceMaps: sourceMaps + }; + } + // In non Emit builder, clear affected files pending emit + else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) { + ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + // State can clear affected files pending emit if + if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared + // If every file pending emit is pending on only dts emit + || ts.every(state.affectedFilesPendingEmit, function (path, index) { + return index < state.affectedFilesPendingEmitIndex || + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; + })) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped: emitSkipped, - diagnostics: diagnostics || ts.emptyArray, - emittedFiles: emittedFiles, - sourceMaps: sourceMaps - }; } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** * Return the semantic diagnostics for the next affected file or undefined if iteration is complete @@ -120478,7 +120894,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { // Done return undefined; @@ -120490,7 +120906,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -120702,7 +121118,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -120759,7 +121175,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); @@ -120914,8 +121330,8 @@ var ts; !!redirectedReference; var seenNamesInFile = ts.createModeAwareCache(); var i = 0; - for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { - var entry = names_4[_i]; + for (var _i = 0, names_5 = names; _i < names_5.length; _i++) { + var entry = names_5[_i]; var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase(); // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant // they require calculating the mode for a given import from it's position in the resolution table, since a given @@ -121059,7 +121475,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -121236,7 +121652,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -121247,7 +121663,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -121387,7 +121803,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -121455,33 +121871,33 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { var _a; - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { return false; } @@ -121525,14 +121941,14 @@ var ts; if (options === void 0) { options = {}; } var info = getInfo(importingSourceFile.path, host); var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); }); } moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) { if (options === void 0) { options = {}; } var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { @@ -121589,7 +122005,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -121608,7 +122024,7 @@ var ts; var relativeSpecifiers; for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { var modulePath = modulePaths_1[_i]; - var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", @@ -121650,7 +122066,7 @@ var ts; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -121664,10 +122080,10 @@ var ts; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -121701,7 +122117,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -121709,7 +122125,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -121880,11 +122296,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -121925,23 +122341,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -121968,9 +122384,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -122001,7 +122417,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) { + function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) { var path = _a.path, isRedirect = _a.isRedirect; var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { @@ -122015,8 +122431,9 @@ var ts; var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; - var moduleFileNameForExtensionless = void 0; + var moduleFileName = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; @@ -122033,12 +122450,12 @@ var ts; isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) - moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) + moduleFileName = moduleFileToTry; // try with next level of directory packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -122066,7 +122483,7 @@ var ts; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); - if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` @@ -122090,13 +122507,13 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Ending.Minimal */, options), versionPaths.paths); if (fromPaths !== undefined) { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name - var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -122104,24 +122521,21 @@ var ts; } } } - return { moduleFileToTry: moduleFileToTry }; - } - function getExtensionlessFileName(path) { - // We still have a file name - remove the extension - var fullModulePathWithoutExtension = ts.removeFileExtension(path); - // If the file is /index, it can be imported by its directory name - // IFF there is not _also_ a file by the same name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + // No package.json exists; an index.js will still resolve as the package name + var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath }; + } } - return fullModulePathWithoutExtension; + return { moduleFileToTry: moduleFileToTry }; } } function tryGetAnyFileFromPath(host, path) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -122136,18 +122550,24 @@ var ts; return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } - function removeExtensionAndIndexPostFix(fileName, ending, options) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + function removeExtensionAndIndexPostFix(fileName, ending, options, host) { + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: - return ts.removeSuffix(noExtension, "/index"); - case 1 /* Index */: + case 0 /* Ending.Minimal */: + var withoutIndex = ts.removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + // Can't remove index if there's a file by the same name as the directory. + // Probably more callers should pass `host` so we can determine this? + return noExtension; + } + return withoutIndex; + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -122155,28 +122575,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -122258,8 +122678,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -122267,8 +122687,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -122291,7 +122711,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -122324,7 +122744,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -122337,7 +122757,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -122360,7 +122780,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -122387,9 +122807,9 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; @@ -122422,14 +122842,14 @@ var ts; var configFile = program.getCompilerOptions().configFile; if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs)) return undefined; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -122438,7 +122858,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -122562,7 +122982,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -122662,6 +123082,7 @@ var ts; createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -122721,6 +123142,7 @@ var ts; createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } ts.createProgramHost = createProgramHost; @@ -122809,6 +123231,7 @@ var ts; var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -122891,7 +123314,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -123047,10 +123470,10 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -123211,7 +123634,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -123271,7 +123694,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -123312,7 +123735,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -123553,7 +123976,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -123598,9 +124021,6 @@ var ts; function newer(date1, date2) { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); - } /*@internal*/ function isCircularBuildOrder(buildOrder) { return !!buildOrder && !!buildOrder.buildOrder; @@ -123616,8 +124036,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -124163,7 +124583,7 @@ var ts; outputFiles.forEach(function (_a) { var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; var priorChangeTime; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && ts.isDeclarationFileName(name)) { // Check for unchanged .d.ts files if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); @@ -124392,7 +124812,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -124421,7 +124841,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -124449,7 +124869,7 @@ var ts; if (!host.fileExists(inputFile)) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (!force) { @@ -124504,7 +124924,7 @@ var ts; // In addition to file timestamps, we also keep track of when a .d.ts file // had its file touched but not had its contents changed - this allows us // to skip a downstream typecheck - if (isDeclarationFile(output)) { + if (ts.isDeclarationFileName(output)) { var outputModifiedTime = ts.getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -124658,7 +125078,7 @@ var ts; reportVerbose = false; reportStatus(state, verboseMessage, proj.options.configFilePath); } - if (isDeclarationFile(file)) { + if (ts.isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); @@ -124808,7 +125228,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -124911,7 +125331,7 @@ var ts; if (!state.watch || !state.lastCachedPackageJsonLookups) return; ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { - createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, onDeleteValue: ts.closeFileWatcher, }); } @@ -125146,7 +125566,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -125157,7 +125577,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -125210,7 +125630,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -125283,7 +125703,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -125297,7 +125717,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -125306,7 +125726,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -125328,7 +125748,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -125356,7 +125776,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -125372,7 +125792,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -125391,12 +125811,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -125422,7 +125842,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -125450,16 +125870,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -125467,20 +125887,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -125491,17 +125911,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -125656,6 +126076,17 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + // Do not change existing values, as they exist in telemetry. + var CompletionInfoFlags; + (function (CompletionInfoFlags) { + CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports"; + CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion"; + CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers"; + CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit"; + CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets"; + })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {})); var OutliningSpanKind; (function (OutliningSpanKind) { /** Single or multi-line comments */ @@ -125862,7 +126293,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -125873,66 +126304,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -125940,7 +126371,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -125949,24 +126380,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -125974,11 +126405,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -125990,27 +126421,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -126019,17 +126450,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -126096,7 +126527,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -126157,22 +126588,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -126196,17 +126627,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -126214,108 +126645,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -126380,42 +126811,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -126424,66 +126855,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -126500,7 +126931,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -126543,13 +126974,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -126608,11 +127039,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -126702,30 +127133,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -126751,7 +127182,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -126767,13 +127198,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -126792,12 +127223,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -126805,13 +127236,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -126822,20 +127253,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -126850,29 +127281,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -126943,23 +127374,23 @@ var ts; // position and whose end is greater than the position. var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input if (nodeContainsPosition(children[middle])) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -126985,7 +127416,7 @@ var ts; return false; } var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -127054,7 +127485,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -127066,11 +127497,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -127095,7 +127526,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -127126,7 +127557,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -127162,25 +127593,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -127199,10 +127630,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -127211,17 +127642,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -127311,10 +127742,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -127324,56 +127755,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -127405,52 +127836,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -127458,7 +127889,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -127468,9 +127899,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -127483,18 +127914,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -127502,7 +127933,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -127525,8 +127956,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -127564,32 +127995,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -127598,7 +128029,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -127626,7 +128057,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -127641,7 +128072,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -127668,6 +128099,14 @@ var ts; return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } }); } ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost; + function moduleResolutionRespectsExports(moduleResolution) { + return moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports; + function moduleResolutionUsesNodeModules(moduleResolution) { + return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext; + } + ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules; function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) { return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined; } @@ -127682,7 +128121,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -127691,25 +128130,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -127720,12 +128159,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -127769,7 +128208,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -127947,34 +128386,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -128051,7 +128490,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -128078,8 +128517,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -128129,22 +128568,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -128154,7 +128593,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -128182,10 +128621,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -128274,14 +128713,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -128300,7 +128739,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -128317,7 +128756,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -128374,7 +128813,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -128400,7 +128839,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -128408,15 +128847,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -128427,15 +128866,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -128444,10 +128883,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -128467,9 +128906,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -128481,48 +128920,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -128542,12 +128981,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -128571,7 +129010,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -128580,10 +129019,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -128707,16 +129146,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -128811,7 +129250,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -128931,20 +129370,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -128977,7 +129416,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -128995,7 +129434,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -129008,7 +129447,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -129028,7 +129467,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -129100,7 +129539,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -129109,7 +129548,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -129117,8 +129556,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -129207,9 +129646,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -129222,7 +129661,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -129271,8 +129710,8 @@ var ts; if (from === to) return false; var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {}); - if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) { - return cachedResult.isAutoImportable; + if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) { + return !cachedResult.isBlockedByPackageJsonDependencies; } var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); @@ -129286,7 +129725,7 @@ var ts; }); if (packageJsonFilter) { var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); - moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable); return isAutoImportable; } return hasImportablePath; @@ -129311,7 +129750,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -129348,24 +129787,31 @@ var ts; (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results"); var compilerOptions = program.getCompilerOptions(); var moduleCount = 0; - forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { - if (++moduleCount % 100 === 0) - cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); - var seenExports = new ts.Map(); - var checker = program.getTypeChecker(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - // Note: I think we shouldn't actually see resolved module symbols here, but weird merges - // can cause it to happen: see 'completionsImport_mergedReExport.ts' - if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); - } - checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { - if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + try { + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { + if (++moduleCount % 100 === 0) + cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); + var seenExports = new ts.Map(); + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + // Note: I think we shouldn't actually see resolved module symbols here, but weird merges + // can cause it to happen: see 'completionsImport_mergedReExport.ts' + if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } + checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); + } + }); }); - }); - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + } + catch (err) { + // Ensure cache is reset if operation is cancelled + cache.clear(); + throw err; + } + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -129384,10 +129830,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -129396,7 +129842,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -129406,8 +129852,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -129419,7 +129865,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -129429,15 +129875,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -129463,10 +129909,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -129502,68 +129948,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -129572,15 +130018,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -129594,59 +130040,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -129688,23 +130134,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -129718,10 +130164,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -129734,19 +130180,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -129754,47 +130200,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -129802,12 +130248,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -129815,36 +130261,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -129864,13 +130310,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -129895,10 +130341,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -129907,29 +130353,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -129938,35 +130384,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -129992,11 +130438,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -130018,12 +130464,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -130031,21 +130477,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -130054,7 +130500,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -130065,7 +130511,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -130074,7 +130520,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -130087,51 +130533,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -130150,7 +130596,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -130160,7 +130606,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -130185,9 +130631,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -130201,19 +130647,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -130221,7 +130667,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -130245,7 +130691,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -130272,10 +130718,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -130288,24 +130734,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -130316,97 +130762,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -130482,14 +130928,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -130501,13 +130947,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -130523,7 +130969,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -130532,38 +130978,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -130576,22 +131022,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -130601,17 +131047,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -130653,25 +131099,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -130702,19 +131148,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -130733,16 +131179,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -130758,20 +131204,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -130785,18 +131231,18 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { + case 196 /* SyntaxKind.LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -130808,21 +131254,21 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -130839,7 +131285,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -130852,41 +131298,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -130913,14 +131359,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -130929,10 +131375,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -130943,13 +131389,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -130971,11 +131417,11 @@ var ts; : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -130989,11 +131435,11 @@ var ts; } function isEmitResolutionKindUsingNodeModules(compilerOptions) { return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs || - ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function isEmitModuleResolutionRespectingExportMaps(compilerOptions) { - return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext; } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -131068,16 +131514,16 @@ var ts; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } var foundFileName = void 0; var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { + else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); foundFiles.set(foundFileName, outputExtension); } @@ -131087,7 +131533,7 @@ var ts; } } foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + result.push(nameAndKind(foundFile, "script" /* ScriptElementKind.scriptElement */, ext)); }); } // If possible, get folder completion as well @@ -131158,7 +131604,7 @@ var ts; var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -131169,7 +131615,7 @@ var ts; var _loop_4 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -131230,7 +131676,7 @@ var ts; }); ts.forEach(processedKeys, function (k) { if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(k, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } }); return; @@ -131289,7 +131735,7 @@ var ts; var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); + return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* ScriptElementKind.scriptElement */, extension); }); var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); @@ -131334,7 +131780,7 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, names); @@ -131365,7 +131811,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.push(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -131407,14 +131853,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -131471,7 +131917,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -131513,16 +131959,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -131531,16 +131977,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -131553,7 +131999,7 @@ var ts; KeywordCompletionFilters[KeywordCompletionFilters["TypeAssertionKeywords"] = 6] = "TypeAssertionKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeywords"] = 7] = "TypeKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeyword"] = 8] = "TypeKeyword"; - KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 7] = "Last"; + KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 8] = "Last"; })(KeywordCompletionFilters || (KeywordCompletionFilters = {})); var GlobalsSearch; (function (GlobalsSearch) { @@ -131561,43 +132007,54 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) { + function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) { var _a, _b, _c; var start = ts.timestamp(); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - var resolutionLimitExceeded = false; + // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because + // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a + // relative path into node_modules), and we want to filter those completions out entirely. + // Import statement completions always need specifier resolution because the module specifier is + // part of their `insertText`, not the `codeActions` creating edits away from the cursor. + var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions())); + var skippedAny = false; var ambientCount = 0; var resolvedCount = 0; var resolvedFromCacheCount = 0; var cacheAttemptCount = 0; - var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var result = cb({ + tryResolve: tryResolve, + skippedAny: function () { return skippedAny; }, + resolvedAny: function () { return resolvedCount > 0; }, + resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, + }); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; - function tryResolve(exportInfo, isFromAmbientModule) { + function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { - var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences); + var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences); if (result_1) { ambientCount++; } - return result_1; + return result_1 || "failed"; } - var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; + var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit; var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache) - ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) + ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) : undefined; if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) { - resolutionLimitExceeded = true; + skippedAny = true; } resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0; - resolvedFromCacheCount += exportInfo.length - resolvedCount; + resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0); if (shouldGetModuleSpecifierFromCache) { cacheAttemptCount++; } - return result; + return result || (needsFullResolution ? "failed" : "skipped"); } } function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) { @@ -131617,7 +132074,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -131631,7 +132088,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -131639,21 +132096,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -131670,16 +132127,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -131692,9 +132149,10 @@ var ts; return undefined; var lowerCaseTokenText = location.text.toLowerCase(); var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken); - var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences, - /*isForImportStatementCompletion*/ false, function (context) { + var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences, + /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) { var entries = ts.mapDefined(previousResponse.entries, function (entry) { + var _a; if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) { // Not an auto import or already resolved; keep as is return entry; @@ -131705,10 +132163,14 @@ var ts; } var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin; var info = exportMap.get(file.path, entry.data.exportMapKey); - var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); - if (!result) + var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); + if (result === "skipped") return entry; - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + if (!result || result === "failed") { + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); + return undefined; + } + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -131716,12 +132178,13 @@ var ts; entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)]; return entry; }); - if (!context.resolutionLimitExceeded()) { + if (!context.skippedAny()) { previousResponse.isIncomplete = undefined; } return entries; }); previousResponse.entries = newEntries; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -131730,8 +132193,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -131745,25 +132208,25 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; @@ -131776,17 +132239,17 @@ var ts; getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { + if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { return undefined; } getCompletionEntriesFromSymbols(symbols, entries, /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); } - if (keywordFilters !== 0 /* None */) { + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (!entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } @@ -131803,12 +132266,13 @@ var ts; ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); } return { + flags: completionData.flags, isGlobalCompletion: isInSnippetScope, isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, optionalReplacementSpan: getOptionalReplacementSpan(location), - entries: entries + entries: entries, }; } function isUncheckedFile(sourceFile, compilerOptions) { @@ -131816,9 +132280,9 @@ var ts; } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -131828,12 +132292,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -131852,14 +132316,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -131878,7 +132342,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -131891,7 +132355,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -131908,18 +132372,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -131930,7 +132394,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -131943,8 +132407,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -131954,12 +132418,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -131970,28 +132434,24 @@ var ts; } } if (origin && originIsObjectLiteralMethod(origin)) { - var importAdder = void 0; - (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails); + (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails); if (!preferences.useLabelDetailsInCompletionEntries) { name = name + labelDetails.detail; labelDetails = undefined; } source = CompletionSource.ObjectLiteralMethodSnippet; sortText = Completions.SortText.SortBelow(sortText); - if (importAdder.hasFixes()) { - hasAction = true; - } } if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -132000,7 +132460,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -132042,8 +132502,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -132102,16 +132562,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -132122,13 +132582,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -132139,9 +132599,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -132156,9 +132616,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -132203,8 +132663,7 @@ var ts; var isSnippet = preferences.includeCompletionsWithSnippetText || undefined; var insertText = name; var sourceFile = enclosingDeclaration.getSourceFile(); - var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host); - var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder); + var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences); if (!method) { return undefined; } @@ -132216,10 +132675,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -132232,33 +132691,32 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; - return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; + return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; - function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) { + function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } var checker = program.getTypeChecker(); - var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var declaration = declarations[0]; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -132266,7 +132724,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -132275,47 +132733,72 @@ var ts; if (!typeNode || !ts.isFunctionTypeNode(typeNode)) { return undefined; } - var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); - if (importableReference) { - typeNode = importableReference.typeNode; - ts.codefix.importSymbols(importAdder, importableReference.symbols); - } var body = void 0; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } + var parameters = typeNode.parameters.map(function (typedParam) { + return ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken, + /*type*/ undefined, typedParam.initializer); + }); return ts.factory.createMethodDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, - /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body); + /*questionToken*/ undefined, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } default: return undefined; } } function createSnippetPrinter(printerOptions) { + var escapes; var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions)); var printer = ts.createPrinter(printerOptions, baseWriter); - var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } }); + var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } }); return { printSnippetList: printSnippetList, printAndFormatSnippetList: printAndFormatSnippetList, }; + // The formatter/scanner will have issues with snippet-escaped text, + // so instead of writing the escaped text directly to the writer, + // generate a set of changes that can be applied to the unescaped text + // to escape it post-formatting. + function escapingWrite(s, write) { + var escaped = ts.escapeSnippetText(s); + if (escaped !== s) { + var start = baseWriter.getTextPos(); + write(); + var end = baseWriter.getTextPos(); + escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } }); + } + else { + write(); + } + } /* Snippet-escaping version of `printer.printList`. */ function printSnippetList(format, list, sourceFile) { + var unescaped = printUnescapedSnippetList(format, list, sourceFile); + return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped; + } + function printUnescapedSnippetList(format, list, sourceFile) { + escapes = undefined; writer.clear(); printer.writeList(format, list, sourceFile, writer); return writer.getText(); } function printAndFormatSnippetList(format, list, sourceFile, formatContext) { var syntheticFile = { - text: printSnippetList(format, list, sourceFile), + text: printUnescapedSnippetList(format, list, sourceFile), getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); }, @@ -132327,7 +132810,10 @@ var ts; /* indentation */ 0, /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions })); }); - return ts.textChanges.applyChanges(syntheticFile.text, changes); + var allChanges = escapes + ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); }) + : changes; + return ts.textChanges.applyChanges(syntheticFile.text, allChanges); } } function originToCompletionEntryData(origin) { @@ -132353,11 +132839,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -132369,7 +132855,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -132385,21 +132871,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -132410,7 +132896,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -132419,10 +132905,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -132441,7 +132927,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -132494,7 +132980,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -132502,7 +132988,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -132526,8 +133012,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -132558,7 +133044,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -132572,8 +133058,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -132593,14 +133079,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -132612,22 +133098,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -132656,20 +133142,6 @@ var ts; }; } } - if (source === CompletionSource.ObjectLiteralMethodSnippet) { - var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken); - var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder; - if (importAdder.hasFixes()) { - var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes); - return { - sourceDisplay: undefined, - codeActions: [{ - changes: changes, - description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]), - }], - }; - } - } if (originIsTypeOnlyAlias(origin)) { var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences); ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias"); @@ -132681,7 +133153,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -132713,7 +133185,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -132721,31 +133193,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -132753,14 +133225,14 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -132776,10 +133248,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -132800,7 +133272,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -132810,21 +133282,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -132855,15 +133327,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -132876,6 +133349,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -132885,11 +133359,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -132897,7 +133371,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -132905,18 +133379,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -132924,58 +133398,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -132983,16 +133457,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -133001,7 +133475,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -133020,8 +133494,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -133029,8 +133503,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -133044,10 +133518,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -133068,16 +133542,17 @@ var ts; isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, + flags: flags, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -133086,13 +133561,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -133107,7 +133582,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -133115,7 +133590,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -133129,7 +133604,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -133143,7 +133618,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -133167,7 +133642,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -133175,7 +133650,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; if (inUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -133222,21 +133697,21 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, symbol: firstAccessibleSymbol, targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags, - }], sourceFile, program, host, preferences) || {}).moduleSpecifier; + }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -133267,15 +133742,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -133291,44 +133766,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -133363,7 +133838,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -133373,21 +133848,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -133396,8 +133871,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -133421,10 +133896,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -133440,29 +133915,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -133477,6 +133952,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -133488,50 +133964,72 @@ var ts; var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken); var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host); var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host); - resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) { + resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) { exportInfo.search(sourceFile.path, /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) { if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings()))) return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText); }, function (info, symbolName, isFromAmbientModule, exportMapKey) { + var _a; if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) { return; } - var defaultExportInfo = ts.find(info, isImportableExportInfo); - if (!defaultExportInfo) { + // Do a relatively cheap check to bail early if all re-exports are non-importable + // due to file location or package.json dependency filtering. For non-node16+ + // module resolution modes, getting past this point guarantees that we'll be + // able to generate a suitable module specifier, so we can safely show a completion, + // even if we defer computing the module specifier. + var firstImportableExportInfo = ts.find(info, isImportableExportInfo); + if (!firstImportableExportInfo) { return; } - // If we don't need to resolve module specifiers, we can use any re-export that is importable at all - // (We need to ensure that at least one is importable to show a completion.) - var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier; - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + // In node16+, module specifier resolution can fail due to modules being blocked + // by package.json `exports`. If that happens, don't show a completion item. + // N.B. in this resolution mode we always try to resolve module specifiers here, + // because we have to know now if it's going to fail so we can omit the completion + // from the list. + var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {}; + if (result === "failed") + return; + // If we skipped resolving module specifiers, our selection of which ExportInfo + // to use here is arbitrary, since the info shown in the completion list derived from + // it should be identical regardless of which one is used. During the subsequent + // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick + // the best one based on the module specifier it produces. + var exportInfo = firstImportableExportInfo, moduleSpecifier; + if (result !== "skipped") { + (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); + } + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, isFromPackageJson: exportInfo.isFromPackageJson, }); }); - hasUnresolvedAutoImports = context.resolutionLimitExceeded(); + hasUnresolvedAutoImports = context.skippedAny(); + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -133568,7 +134066,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -133578,7 +134076,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -133593,7 +134092,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -133620,27 +134119,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -133651,45 +134150,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -133708,21 +134207,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -133734,22 +134233,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -133759,12 +134258,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -133775,19 +134274,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -133799,14 +134298,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -133823,38 +134322,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -133867,14 +134366,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -133883,7 +134382,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -133892,48 +134391,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -133947,8 +134446,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -133978,23 +134477,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134005,8 +134504,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134014,10 +134513,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134025,7 +134524,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -134044,75 +134543,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -134133,21 +134632,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -134156,7 +134655,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -134167,7 +134666,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -134183,22 +134682,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -134216,13 +134715,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -134235,7 +134734,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -134269,7 +134768,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -134294,7 +134793,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -134313,10 +134812,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -134324,11 +134823,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -134339,7 +134838,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -134358,7 +134857,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -134381,15 +134880,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -134412,12 +134911,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -134426,27 +134925,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -134456,11 +134955,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -134469,7 +134968,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 7 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -134478,30 +134977,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -134509,63 +135008,63 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -134586,9 +135085,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -134604,7 +135103,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -134626,7 +135125,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -134634,7 +135133,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -134652,15 +135151,15 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -134674,22 +135173,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -134700,7 +135199,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -134709,15 +135208,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -134734,11 +135233,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -134760,13 +135259,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -134779,22 +135278,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -134802,7 +135301,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -134819,7 +135318,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -134827,23 +135326,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -134853,12 +135352,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -134898,8 +135397,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -134936,8 +135435,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -134951,7 +135450,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -134981,7 +135480,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -135011,45 +135510,47 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); + case 101 /* SyntaxKind.InKeyword */: + return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -135091,7 +135592,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -135123,16 +135624,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -135148,41 +135649,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -135201,12 +135702,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -135214,7 +135715,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -135223,13 +135724,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -135237,13 +135738,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -135251,13 +135752,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -135268,13 +135769,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -135286,11 +135787,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -135302,13 +135803,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -135323,7 +135824,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -135342,7 +135843,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -135357,7 +135858,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -135377,10 +135878,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -135464,7 +135965,7 @@ var ts; } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { @@ -135472,7 +135973,7 @@ var ts; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); var sourceFileOptions = { languageVersion: scriptTarget, impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), @@ -135485,15 +135986,15 @@ var ts; // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). - var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) && + var otherBucketKey = !ts.isDeclarationFileName(path) && ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); } } var bucketEntry = bucket.get(path); @@ -135607,18 +136108,18 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -135685,43 +136186,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -135730,7 +136231,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -135752,18 +136253,18 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* SyntaxKind.ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -135785,7 +136286,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -135819,33 +136320,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -135854,12 +136355,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -135870,7 +136371,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -135882,7 +136383,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -135907,7 +136408,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -135916,7 +136417,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -135936,7 +136437,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -135984,7 +136485,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -135999,15 +136500,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -136032,7 +136533,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -136045,21 +136546,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -136077,24 +136578,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -136121,22 +136622,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -136166,16 +136667,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; @@ -136205,7 +136706,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -136216,21 +136717,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -136257,7 +136758,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -136285,7 +136786,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -136324,7 +136825,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -136333,7 +136834,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -136341,28 +136842,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -136403,7 +136904,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -136420,19 +136921,19 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } else { @@ -136455,18 +136956,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -136474,7 +136975,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -136493,7 +136994,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -136501,32 +137002,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -136534,7 +137035,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -136557,19 +137058,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -136579,7 +137080,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -136587,10 +137088,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -136624,12 +137125,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -136637,16 +137138,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -136655,17 +137156,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -136680,14 +137181,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -136695,9 +137196,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -136708,50 +137209,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -136780,7 +137281,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -136802,7 +137303,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -136812,11 +137313,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -136827,10 +137328,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -136858,7 +137359,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -136878,10 +137379,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -136909,13 +137410,13 @@ var ts; continue; } var _loop_5 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -136946,7 +137447,7 @@ var ts; return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -136967,7 +137468,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -136977,21 +137478,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -136999,41 +137500,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -137049,7 +137550,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -137058,20 +137559,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -137094,17 +137595,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -137117,10 +137618,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -137134,7 +137635,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -137186,7 +137687,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -137209,7 +137710,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -137217,7 +137718,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -137248,19 +137749,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -137273,7 +137774,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -137301,13 +137802,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -137317,7 +137818,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -137343,17 +137844,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -137370,7 +137871,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -137382,7 +137883,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -137430,6 +137931,30 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function getTopMostDeclarationNamesInFile(declarationName, sourceFile) { + var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); }); + return candidates.reduce(function (topMost, decl) { + var depth = getDepth(decl); + if (!ts.some(topMost.declarationNames) || depth === topMost.depth) { + topMost.declarationNames.push(decl); + topMost.depth = depth; + } + else if (depth < topMost.depth) { + topMost.declarationNames = [decl]; + topMost.depth = depth; + } + return topMost; + }, { depth: Infinity, declarationNames: [] }).declarationNames; + function getDepth(declaration) { + var depth = 0; + while (declaration) { + declaration = ts.getContainerNode(declaration); + depth++; + } + return depth; + } + } + Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile; function someSignatureUsage(signature, sourceFiles, checker, cb) { if (!signature.name || !ts.isIdentifier(signature.name)) return false; @@ -137477,8 +138002,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -137493,27 +138018,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -137529,7 +138054,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -137540,7 +138065,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -137591,7 +138116,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -137601,14 +138126,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -137616,7 +138141,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -137636,7 +138161,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -137646,7 +138171,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -137657,9 +138182,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -137667,7 +138192,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -137694,11 +138219,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -137718,14 +138243,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -137743,7 +138268,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -137759,7 +138284,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -137770,7 +138295,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -137789,18 +138314,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -137811,7 +138336,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -137821,10 +138346,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -137848,10 +138373,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -137871,7 +138396,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -137899,13 +138424,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -137956,15 +138481,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -137973,7 +138498,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -137982,46 +138507,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -138029,26 +138554,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -138061,18 +138586,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -138117,30 +138642,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -138150,14 +138675,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -138172,7 +138697,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -138180,7 +138705,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -138192,13 +138717,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -138220,7 +138745,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -138234,12 +138759,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -138249,7 +138774,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -138289,7 +138814,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -138300,7 +138825,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -138329,12 +138854,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -138354,7 +138879,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -138403,7 +138928,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -138427,8 +138952,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -138448,7 +138973,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -138461,16 +138986,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -138568,7 +139093,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -138579,7 +139104,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -138609,7 +139134,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -138639,7 +139164,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -138667,7 +139192,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -138684,59 +139209,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -138753,7 +139278,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -138792,25 +139317,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -138826,7 +139351,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -139066,7 +139591,9 @@ var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { - function getDefinitionAtPosition(program, sourceFile, position) { + function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) { + var _a; + var _b; var resolvedRef = getReferenceAtPosition(sourceFile, position, program); var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { @@ -139079,45 +139606,75 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; - var symbol_1 = getSymbol(classDecl, typeChecker); + var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution; var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration); var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : ""; var sourceFile_1 = node.getSourceFile(); return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } - var symbol = getSymbol(node, typeChecker); + var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; + var fallbackNode = node; + if (searchOtherFilesOnly && failedAliasResolution) { + // We couldn't resolve the specific import, try on the module specifier. + var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); }); + var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration); + if (moduleSpecifier) { + (_a = getSymbol(moduleSpecifier, typeChecker, stopAtAlias), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution); + fallbackNode = moduleSpecifier; + } + } + if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) { + // We couldn't resolve the module specifier as an external module, but it could + // be that module resolution succeeded but the target was not a module. + var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode)); + if (ref) { + return [{ + name: fallbackNode.text, + fileName: ref.resolvedFileName, + containerName: undefined, + containerKind: undefined, + kind: "script" /* ScriptElementKind.scriptElement */, + textSpan: ts.createTextSpan(0, 0), + failedAliasResolution: failedAliasResolution, + isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), + unverified: fallbackNode !== node, + }]; + } + } // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } + if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; })) + return undefined; var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) { - var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); + var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) { return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -139125,9 +139682,9 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray; + var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the @@ -139150,7 +139707,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -139248,24 +139805,24 @@ var ts; return undefined; } if (ts.isImportMeta(node.parent) && node.parent.name === node) { - return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent); + return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false); } - var symbol = getSymbol(node, typeChecker); + var _a = getSymbol(node, typeChecker, /*stopAtAlias*/ false), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution; if (!symbol) return undefined; var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node); var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker); - var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node); + var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution); // If a function returns 'void' or some other type with no definition, just return the function definition. - var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node); + var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; - function definitionFromType(type, checker, node) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { - return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node); + function definitionFromType(type, checker, node, failedAliasResolution) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { + return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } function tryGetReturnTypeOfFunction(symbol, type, checker) { @@ -139301,19 +139858,23 @@ var ts; function getDefinitionInfoForIndexSignatures(node, checker) { return ts.mapDefined(checker.getIndexInfosAtLocation(node), function (info) { return info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); }); } - function getSymbol(node, checker) { + function getSymbol(node, checker, stopAtAlias) { var symbol = checker.getSymbolAtLocation(node); // If this is an alias, and the request came at the declaration location // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + var failedAliasResolution = false; + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { - return aliased; + return { symbol: aliased }; + } + else { + failedAliasResolution = true; } } - return symbol; + return { symbol: symbol, failedAliasResolution: failedAliasResolution }; } // Go to the original declaration for cases: // @@ -139321,36 +139882,55 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - switch (declaration.kind) { - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: - return true; - case 270 /* ImportSpecifier */: - return declaration.parent.kind === 269 /* NamedImports */; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); - default: - return false; + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { + return false; } + return true; + } + /** + * ```ts + * function f() {} + * f.foo = 0; + * ``` + * + * Here, `f` has two declarations: the function declaration, and the identifier in the next line. + * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so + * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a + * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this + * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the + * declaration looks like an assignment, that declaration is in no sense a definition for `f`. + * But that information is totally lost during binding and/or symbol merging, so we need to do + * our best to reconstruct it or use other heuristics. This function (and the logic around its + * calling) covers our tests but feels like a hack, and it would be great if someone could come + * up with a more precise definition of what counts as a definition. + */ + function isExpandoDeclaration(node) { + if (!ts.isAssignmentDeclaration(node)) + return false; + var containingAssignment = ts.findAncestor(node, function (p) { + if (ts.isAssignmentExpression(p)) + return true; + if (!ts.isAssignmentDeclaration(p)) + return "quit"; + return false; + }); + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; } - function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { - // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties. - // For deduping purposes, we also want to exclude any declarationNodes if provided. - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) - || undefined; - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); + var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); }); + var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -139370,26 +139950,27 @@ var ts; return declarations.length ? declarationsWithBody.length !== 0 ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) - : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)] : undefined; } } /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ - function createDefinitionInfo(declaration, checker, symbol, node) { + function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) { var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node); var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : ""; - return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName); + return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution); } + GoToDefinition.createDefinitionInfo = createDefinitionInfo; /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) { + function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) { var sourceFile = declaration.getSourceFile(); if (!textSpan) { var name = ts.getNameOfDeclaration(declaration) || declaration; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -139401,29 +139982,29 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; } } - function createDefinitionFromSignatureDeclaration(typeChecker, decl) { - return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); + function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) { + return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution); } function findReferenceInPosition(refs, pos) { return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); @@ -139433,7 +140014,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -139454,9 +140035,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -139568,10 +140149,10 @@ var ts; // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = getDisplayPartsFromComment(jsdoc.comment, checker); @@ -139588,11 +140169,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -139606,8 +140187,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -139622,17 +140203,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -139646,7 +140227,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -139654,13 +140235,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -139687,14 +140268,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -139704,7 +140285,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -139715,8 +140296,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -139726,7 +140307,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139752,14 +140333,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -139846,37 +140427,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -139886,25 +140467,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -139917,14 +140498,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -139983,9 +140564,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -139995,7 +140576,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -140012,7 +140593,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -140046,7 +140627,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -140229,7 +140810,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -140242,7 +140823,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -140254,25 +140835,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -140284,7 +140865,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -140295,17 +140876,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -140315,7 +140896,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -140323,11 +140904,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -140337,9 +140918,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -140347,10 +140928,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -140364,27 +140945,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -140398,7 +140979,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -140418,10 +140999,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -140434,7 +141015,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -140452,9 +141033,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -140510,16 +141091,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -140527,10 +141108,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -140596,7 +141177,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -140615,12 +141196,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -140628,7 +141209,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -140642,7 +141223,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -140672,7 +141253,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -140681,53 +141262,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -140760,19 +141341,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -140782,10 +141363,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -140847,7 +141428,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -140861,13 +141442,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -140882,7 +141463,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -140890,7 +141471,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -140901,10 +141482,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -140917,7 +141498,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -140925,9 +141506,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -141041,7 +141622,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -141059,7 +141640,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -141328,11 +141909,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -141371,19 +141952,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -141436,7 +142017,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -141444,7 +142025,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -141494,7 +142075,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -141529,7 +142110,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -141545,9 +142126,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -141558,7 +142139,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -141572,7 +142153,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -141580,23 +142161,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -141604,52 +142185,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -141660,33 +142241,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -141695,32 +142276,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -141730,12 +142311,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -141861,7 +142442,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -141913,7 +142494,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -141990,10 +142571,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -142003,10 +142584,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -142031,10 +142612,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -142043,10 +142624,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -142115,35 +142696,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -142204,7 +142785,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -142225,10 +142806,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -142258,12 +142839,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -142275,54 +142856,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -142331,18 +142912,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -142350,15 +142931,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -142374,31 +142955,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -142406,31 +142987,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -142444,12 +143025,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -142460,16 +143041,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -142478,15 +143059,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -142514,31 +143095,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -142625,13 +143206,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -142644,14 +143225,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -142660,7 +143241,7 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { @@ -142671,7 +143252,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -142681,7 +143262,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -142711,13 +143292,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -142749,7 +143330,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -142817,7 +143398,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -142874,26 +143455,26 @@ var ts; if (ts.isMappedTypeNode(node)) { var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -142905,7 +143486,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -142918,14 +143499,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -142981,7 +143562,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -142996,25 +143577,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -143061,7 +143642,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -143075,27 +143656,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -143105,20 +143686,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -143154,7 +143735,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -143171,7 +143752,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -143214,7 +143795,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -143224,10 +143805,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -143252,7 +143833,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -143262,7 +143843,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -143291,28 +143872,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -143322,7 +143903,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -143344,7 +143925,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -143363,8 +143944,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -143402,7 +143983,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -143433,7 +144014,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -143445,7 +144026,7 @@ var ts; var _loop_9 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; @@ -143465,17 +144046,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -143532,10 +144113,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -143568,9 +144149,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -143578,33 +144159,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -143617,7 +144198,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -143638,14 +144219,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -143681,25 +144262,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -143713,7 +144294,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name)) { @@ -143785,17 +144366,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -143804,7 +144385,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -143827,7 +144408,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -143869,13 +144450,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -143937,7 +144518,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -144046,7 +144627,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -144082,7 +144663,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -144104,16 +144685,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -144125,12 +144706,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -144200,26 +144781,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -144232,28 +144813,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -144266,32 +144847,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -144299,52 +144880,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -144352,23 +144933,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -144378,10 +144959,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -144389,10 +144970,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -144403,41 +144984,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -144457,7 +145038,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -144465,21 +145046,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -144488,29 +145069,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -144520,31 +145101,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -144554,63 +145135,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -144621,7 +145202,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -144629,21 +145210,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -144651,22 +145232,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -144675,7 +145256,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -144691,42 +145272,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -144736,30 +145317,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144770,17 +145351,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -144796,14 +145377,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -144854,23 +145435,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -144885,31 +145466,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -144921,7 +145502,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -144933,16 +145514,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -145147,8 +145728,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -145166,8 +145747,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -145179,7 +145760,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -145207,7 +145788,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -145235,11 +145816,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -145247,12 +145828,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -145261,29 +145842,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -145315,7 +145896,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -145326,40 +145907,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -145368,15 +145949,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -145443,8 +146024,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -145456,263 +146037,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -145730,7 +146311,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -145771,54 +146352,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -145830,22 +146411,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -145871,34 +146452,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -145907,40 +146488,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -145949,71 +146530,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -146028,45 +146609,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -146077,28 +146658,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -146120,15 +146701,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -146137,25 +146718,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -146184,17 +146765,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -146243,12 +146824,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -146274,7 +146855,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -146343,16 +146924,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -146374,12 +146955,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -146387,7 +146968,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -146396,7 +146977,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -146436,17 +147017,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -146543,11 +147124,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -146561,7 +147142,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -146589,7 +147170,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -146634,7 +147215,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -146649,7 +147230,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -146662,8 +147243,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -146686,19 +147267,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -146713,12 +147294,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -146745,26 +147326,26 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: - case 228 /* ExpressionWithTypeArguments */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -146799,7 +147380,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -146812,6 +147393,9 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + if (ts.nodeIsMissing(child)) { + return inheritedIndentation; + } var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; var undecoratedChildStartLine = childStartLine; @@ -146819,10 +147403,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -146858,17 +147442,17 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -146878,7 +147462,14 @@ var ts; var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; - if (listStartToken !== 0 /* Unknown */) { + // node range is outside the target range - do not dive inside + if (!ts.rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { + if (nodes.end < originalRange.pos) { + formattingScanner.skipToEndOf(nodes); + } + return; + } + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -146891,7 +147482,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -146910,15 +147501,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */ && ts.isCallLikeExpression(parent)) { var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; if (startLine !== commaTokenLine) { formattingScanner.advance(); @@ -146942,7 +147533,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -146952,13 +147543,13 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } @@ -146968,15 +147559,15 @@ var ts; if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -146990,19 +147581,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -147020,7 +147611,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -147041,7 +147632,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -147049,14 +147640,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -147065,15 +147656,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -147099,7 +147690,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -147230,48 +147821,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -147313,53 +147904,53 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -147445,7 +148036,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -147481,21 +148072,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -147515,7 +148106,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -147540,9 +148131,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -147551,7 +148142,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -147605,12 +148196,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -147649,7 +148240,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -147660,9 +148251,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -147675,13 +148266,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -147691,9 +148282,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -147708,8 +148299,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -147789,42 +148380,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -147842,27 +148433,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -147871,7 +148462,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -147881,7 +148472,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -147902,7 +148493,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -147918,98 +148509,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -148020,11 +148611,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -148114,7 +148705,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -148198,7 +148789,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -148241,7 +148832,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -148347,7 +148938,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -148411,7 +149002,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -148464,7 +149055,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -148473,19 +149064,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -148626,8 +149217,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -148635,22 +149226,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -148659,28 +149250,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -148735,7 +149326,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -148752,12 +149343,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -148780,7 +149371,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -148857,10 +149448,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -148872,16 +149463,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -148890,8 +149481,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -148911,7 +149502,7 @@ var ts; var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); var _loop_12 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. @@ -148938,8 +149529,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -148994,7 +149585,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -149002,7 +149593,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -149012,7 +149603,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -149223,7 +149814,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -149263,7 +149854,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -149275,18 +149866,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -149297,17 +149888,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -149315,13 +149906,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -149330,17 +149921,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -149369,7 +149960,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -149391,15 +149982,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -149408,14 +149999,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -149602,8 +150193,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -149688,7 +150279,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -149738,7 +150329,7 @@ var ts; ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, - ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, + ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code, @@ -149832,12 +150423,12 @@ var ts; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -149905,15 +150496,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -150002,7 +150593,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -150026,16 +150617,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -150049,9 +150640,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -150061,10 +150652,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -150099,9 +150690,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -150216,7 +150807,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -150256,7 +150847,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -150309,9 +150900,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -150321,7 +150912,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -150336,30 +150927,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -150376,13 +150967,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -150420,11 +151011,11 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -150451,7 +151042,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -150484,14 +151075,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -150542,7 +151133,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -150561,7 +151152,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -150613,7 +151204,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150624,14 +151215,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -150648,7 +151239,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150659,7 +151250,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -150686,7 +151277,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -150747,7 +151338,7 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options); + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, options); var _loop_14 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { @@ -150822,7 +151413,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -150885,7 +151476,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -150966,7 +151557,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -150975,7 +151566,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -150995,7 +151586,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -151011,10 +151602,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -151024,7 +151615,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -151129,12 +151720,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -151150,11 +151741,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -151164,7 +151755,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -151175,8 +151766,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -151278,7 +151869,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -151295,7 +151886,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -151305,7 +151896,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -151387,12 +151978,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -151413,10 +152004,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -151454,10 +152045,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -151497,9 +152088,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -151517,29 +152108,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -151586,8 +152177,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -151595,11 +152186,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -151638,19 +152229,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -151679,8 +152270,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -151695,23 +152286,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -151719,10 +152310,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -151742,7 +152333,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -151757,7 +152348,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -151768,7 +152359,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -151779,10 +152370,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -151839,7 +152430,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -151861,11 +152452,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -151889,7 +152480,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -151919,7 +152510,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -151979,7 +152570,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -152148,7 +152739,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -152161,10 +152752,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -152260,7 +152851,7 @@ var ts; var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider); var useRequire = shouldUseRequire(sourceFile, program); - var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); + var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); if (fix) { addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined }); } @@ -152270,20 +152861,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -152296,32 +152887,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -152349,13 +152940,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -152365,7 +152956,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -152430,7 +153021,7 @@ var ts; : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences)); + var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences)); return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, @@ -152443,13 +153034,13 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; - function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host); - return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host); + return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; @@ -152471,7 +153062,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -152494,7 +153085,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -152504,25 +153095,32 @@ var ts; return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); } } - function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { - var _a = getNewImportFixes(program, importingFile, - /*position*/ undefined, - /*isValidTypeOnlyUseSite*/ false, - /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; + function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) { + var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, + /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host); return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount }); } codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; - function getImportFixes(exportInfos, symbolName, + function getImportFixes(exportInfos, useNamespaceInfo, /** undefined only for missing JSX namespace */ - position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) { + isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) { var checker = program.getTypeChecker(); var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); - var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); + var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker); var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions()); - // 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, position, isValidTypeOnlyUseSite, useRequire, host, preferences); - return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true); + if (addToExisting) { + // Don't bother providing an action to add a new import if we can add to an existing one. + return { + computedWithoutCacheCount: 0, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false), + }; + } + var _a = getFixesForAddImport(exportInfos, existingImports, program, sourceFile, useNamespaceInfo === null || useNamespaceInfo === void 0 ? void 0 : useNamespaceInfo.position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly), fixes = _a.fixes, _b = _a.computedWithoutCacheCount, computedWithoutCacheCount = _b === void 0 ? 0 : _b; + return { + computedWithoutCacheCount: computedWithoutCacheCount, + fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true), + }; } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -152538,13 +153136,14 @@ var ts; // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. return ts.firstDefined(existingImports, function (_a) { + var _b; var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -152552,11 +153151,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -152566,11 +153165,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -152579,31 +153178,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -152612,22 +153211,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -152638,7 +153237,7 @@ var ts; function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { @@ -152646,7 +153245,7 @@ var ts; if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } - if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } }); @@ -152684,6 +153283,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); }); + var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions)); var getModuleSpecifiers = fromCacheOnly ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); } : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); }; @@ -152691,38 +153291,39 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; - return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) { - // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return !importedSymbolHasValueMeaning && isJs && position !== undefined - ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } - : { - kind: 3 /* AddNew */, - moduleSpecifier: moduleSpecifier, - importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), - useRequire: useRequire, - addAsTypeOnly: addAsTypeOnly, - exportInfo: exportInfo, - isReExport: i > 0, - }; + return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { + return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : + // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + { + kind: 3 /* ImportFixKind.AddNew */, + moduleSpecifier: moduleSpecifier, + importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), + useRequire: useRequire, + addAsTypeOnly: addAsTypeOnly, + exportInfo: exportInfo, + isReExport: i > 0, + }; }); }); return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes }; } - function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); }); - return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes; + return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly); } function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) { + var _b; var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -152753,23 +153354,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -152792,10 +153393,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -152806,9 +153407,10 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences); + var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; + var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text }; } function getUmdSymbol(token, checker) { @@ -152819,7 +153421,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -152828,10 +153430,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -152839,7 +153441,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -152848,9 +153450,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -152858,12 +153460,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; - case ts.ModuleKind.Node12: + return 2 /* ImportKind.Namespace */; + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -152872,7 +153474,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -152880,19 +153482,19 @@ var ts; var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes; })); return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text }; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -152907,8 +153509,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -152940,7 +153542,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -152951,14 +153553,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -152967,12 +153569,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -152983,45 +153585,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -153029,7 +153631,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -153047,13 +153649,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -153065,7 +153667,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -153075,7 +153677,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -153084,7 +153686,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -153094,7 +153696,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -153145,7 +153747,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -153169,11 +153771,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -153182,12 +153784,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) @@ -153228,7 +153830,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -153265,7 +153867,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -153399,7 +154001,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -153407,19 +154009,19 @@ var ts; changeTracker.filterJSDocTags(sourceFile, classElement, ts.not(ts.isJSDocOverrideTag)); return; } - var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* OverrideKeyword */; }); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* SyntaxKind.OverrideKeyword */; }); ts.Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -153461,7 +154063,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -153501,7 +154103,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -153520,7 +154122,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -153551,7 +154153,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -153560,16 +154162,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -153635,18 +154237,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -153664,7 +154266,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -153697,14 +154299,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -153776,7 +154378,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -153835,7 +154437,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -153879,19 +154481,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -153953,19 +154555,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -153983,20 +154585,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -154020,15 +154622,15 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; @@ -154055,12 +154657,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -154069,7 +154671,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -154077,17 +154679,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -154099,13 +154701,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -154119,15 +154721,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -154143,18 +154745,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -154191,32 +154793,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -154244,7 +154846,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -154269,15 +154871,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -154297,7 +154899,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.decorators, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -154307,7 +154909,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } function addJsxAttributes(changes, context, info) { @@ -154335,7 +154937,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop)); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* QuotePreference.Single */), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -154345,42 +154947,42 @@ var ts; changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -154394,17 +154996,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -154419,8 +155021,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -154444,7 +155046,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -154529,7 +155131,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -154604,7 +155206,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -154647,7 +155249,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -154772,8 +155374,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { var compilerOptions = context.program.getCompilerOptions(); @@ -154791,7 +155393,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -154870,17 +155472,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -154977,7 +155579,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -155084,7 +155686,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -155099,7 +155701,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -155111,11 +155713,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -155123,7 +155725,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -155132,7 +155734,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -155168,7 +155770,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -155210,7 +155812,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -155252,13 +155854,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -155281,7 +155883,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -155292,7 +155894,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -155301,18 +155903,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -155321,15 +155923,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -155337,14 +155939,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -155394,8 +155996,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -155404,7 +156006,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -155425,20 +156027,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -155499,7 +156101,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -155510,8 +156112,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -155560,7 +156162,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -155584,10 +156186,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -155604,7 +156206,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -155621,22 +156223,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -155671,7 +156273,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -155739,15 +156341,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -155762,11 +156364,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -155928,7 +156530,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -156029,9 +156631,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -156039,7 +156641,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -156082,7 +156684,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -156118,7 +156720,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -156126,9 +156728,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -156137,7 +156739,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -156151,7 +156753,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -156169,19 +156771,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -156323,24 +156925,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -156348,20 +156950,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -156385,13 +156987,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -156401,65 +157003,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -156467,31 +157069,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -156511,7 +157113,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -156536,7 +157138,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -156583,21 +157185,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -156616,22 +157218,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -156663,7 +157265,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -156680,7 +157282,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -156708,7 +157310,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -156722,7 +157324,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -156741,10 +157343,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -156758,8 +157360,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -156795,10 +157397,10 @@ var ts; var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); var _loop_16 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; @@ -156806,15 +157408,15 @@ var ts; _loop_16(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -156898,7 +157500,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -156965,7 +157567,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -156978,13 +157580,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -156994,11 +157596,11 @@ var ts; } } addClassElement(ts.factory.createPropertyDeclaration( - /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -157027,8 +157629,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -157036,7 +157638,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!ts.some(signatures)) { break; } @@ -157058,13 +157660,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -157074,11 +157676,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 1073741824 /* NoUndefinedOptionalParameterType */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -157131,7 +157732,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -157163,26 +157764,26 @@ var ts; ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; var typeParameters = isJs || typeArguments === undefined ? undefined : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); + return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* CharacterCodes.T */ + typeArguments.length - 1 <= 90 /* CharacterCodes.Z */ ? String.fromCharCode(84 /* CharacterCodes.T */ + i) : "T".concat(i)); }); var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, /*questionToken*/ undefined, typeParameters, parameters, type); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: @@ -157210,9 +157811,9 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ names && names[i] || "arg".concat(i), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -157242,8 +157843,8 @@ var ts; if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -157259,7 +157860,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -157268,16 +157869,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -157350,7 +157951,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -157423,17 +158024,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -157442,7 +158043,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -157460,13 +158061,13 @@ var ts; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -157522,13 +158123,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -157543,7 +158144,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -157555,7 +158156,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -157602,7 +158203,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -157720,7 +158321,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -157728,7 +158329,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -157757,7 +158358,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -157766,7 +158367,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -157774,7 +158375,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -157950,8 +158551,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -158014,7 +158615,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -158080,7 +158681,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -158138,7 +158739,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -158149,7 +158750,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -158221,7 +158822,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -158258,14 +158859,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -158278,6 +158879,7 @@ var ts; var fixName = "addVoidToPromise"; var fixId = "addVoidToPromise"; var errorCodes = [ + ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code, ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code ]; codefix.registerCodeFix({ @@ -158312,7 +158914,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -158324,14 +158926,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -158407,15 +159009,15 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var checker = program.getTypeChecker(); @@ -158424,22 +159026,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -158449,7 +159051,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -158473,18 +159075,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -158493,15 +159095,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -158522,18 +159124,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -158542,10 +159144,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -158556,7 +159158,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -158567,11 +159169,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -158584,7 +159186,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -158593,7 +159195,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -158612,17 +159214,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -158674,13 +159276,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -158688,11 +159290,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -158705,7 +159307,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -158754,14 +159356,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -158910,7 +159512,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -158926,7 +159528,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -159052,17 +159654,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -159077,7 +159679,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -159123,27 +159725,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -159165,24 +159767,24 @@ var ts; return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -159195,12 +159797,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -159326,7 +159928,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -159334,7 +159936,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -159350,7 +159952,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -159358,7 +159960,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -159454,6 +160056,7 @@ var ts; Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block"); + Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method"); })(Messages = extractSymbol.Messages || (extractSymbol.Messages = {})); var RangeFacts; (function (RangeFacts) { @@ -159462,10 +160065,11 @@ var ts; RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator"; RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; + RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction"; /** * The range is in a function which needs the 'static' modifier in a class */ - RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; + RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion"; })(RangeFacts || (RangeFacts = {})); /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array @@ -159496,11 +160100,12 @@ var ts; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. var rangeFacts = RangeFacts.None; + var thisNode; if (!start || !end) { // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -159534,7 +160139,7 @@ var ts; // the expression. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. @@ -159546,7 +160151,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -159589,20 +160194,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -159626,7 +160231,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -159635,9 +160240,17 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); + if (rangeFacts & RangeFacts.UsesThis) { + var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { + rangeFacts |= RangeFacts.UsesThisInFunction; + } + } return errors; function visit(node) { if (errors) { @@ -159645,8 +160258,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -159657,16 +160270,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -159676,13 +160289,15 @@ var ts; } else { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) { return false; @@ -159692,63 +160307,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps = 0 /* PermittedJumps.None */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; + thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -159757,21 +160373,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -159794,7 +160410,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -159826,7 +160442,7 @@ var ts; */ function collectEnclosingScopes(range) { var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range; - if (range.facts & RangeFacts.UsesThis) { + if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class var containingClass = ts.getContainingClass(current); if (containingClass) { @@ -159840,7 +160456,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -159851,7 +160467,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -159891,11 +160507,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -159941,34 +160557,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -159999,7 +160615,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -160008,7 +160624,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -160027,27 +160643,37 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); var newFunction; + var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { + if (callThis) { + parameters.unshift(ts.factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ "this", + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), + /*initializer*/ undefined)); + } newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -160062,10 +160688,13 @@ var ts; var newNodes = []; // replace range with function call var called = getCalledExpression(scope, range, functionNameText); - var call = ts.factory.createCallExpression(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference + if (callThis) { + callArguments.unshift(ts.factory.createIdentifier("this")); + } + var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -160099,7 +160728,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -160110,7 +160739,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -160125,8 +160754,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -160135,7 +160764,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -160192,9 +160821,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -160207,13 +160836,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -160221,11 +160850,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -160257,16 +160886,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -160276,7 +160905,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -160303,7 +160932,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -160322,7 +160951,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -160332,7 +160961,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -160345,10 +160974,10 @@ var ts; /* decorators */ undefined, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -160595,7 +161224,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -160673,14 +161302,17 @@ var ts; var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes)); } + if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) { + functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod)); + } var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -160724,7 +161356,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -160734,11 +161366,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -160812,7 +161444,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -160839,7 +161471,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -160920,30 +161552,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -161089,7 +161721,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -161120,7 +161752,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -161132,7 +161764,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -161158,7 +161790,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -161342,11 +161974,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -161386,7 +162018,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -161442,25 +162074,25 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -161478,21 +162110,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -161518,7 +162150,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -161542,7 +162174,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -161562,19 +162194,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -161583,7 +162215,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -161595,7 +162227,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -161608,14 +162240,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -161657,7 +162289,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -161674,7 +162306,7 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } function getNewModuleName(movedSymbols) { @@ -161684,7 +162316,7 @@ var ts; var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -161718,7 +162350,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -161736,7 +162368,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -161745,14 +162377,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -161764,7 +162396,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -161774,18 +162406,18 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -161795,11 +162427,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -161856,13 +162488,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -161870,19 +162502,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -161890,13 +162522,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -161904,9 +162536,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -161928,7 +162560,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -161936,28 +162568,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], d.modifiers); switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -161965,26 +162597,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -162047,14 +162679,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -162188,7 +162820,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -162287,7 +162919,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -162317,15 +162949,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -162335,7 +162967,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -162354,14 +162986,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -162373,7 +163005,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -162407,16 +163039,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -162424,8 +163056,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -162435,7 +163067,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -162541,7 +163173,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -162550,7 +163182,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -162575,15 +163207,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -162594,30 +163226,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -162698,16 +163330,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -162725,7 +163357,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -162738,7 +163370,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -162747,7 +163379,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -162839,8 +163471,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -163035,7 +163667,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -163061,7 +163693,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -163121,13 +163753,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -163137,7 +163769,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -163148,17 +163780,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -163185,20 +163817,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -163260,8 +163892,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -163272,7 +163904,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -163320,19 +163952,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -163349,9 +163981,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -163391,7 +164023,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -163443,12 +164075,12 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -163465,12 +164097,12 @@ var ts; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } @@ -163494,7 +164126,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -163506,7 +164138,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -163521,7 +164153,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -163543,16 +164175,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -163573,41 +164205,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -163671,7 +164303,7 @@ var ts; var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -163698,7 +164330,7 @@ var ts; var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -163719,7 +164351,7 @@ var ts; var _a; if (ts.hasStaticModifier(declaration)) return; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) { @@ -163731,7 +164363,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -163790,10 +164422,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -163813,31 +164445,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -163848,12 +164480,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -163866,7 +164498,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -163878,7 +164510,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -163887,8 +164519,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -163957,8 +164589,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -163977,7 +164609,7 @@ var ts; this.fileNameToEntry = new ts.Map(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "initializeHostCache", { count: rootFileNames.length }); for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); @@ -164047,7 +164679,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -164144,7 +164776,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -164174,7 +164806,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -164264,7 +164896,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -164384,7 +165016,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -164574,8 +165206,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -164608,27 +165240,27 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; } } /// Goto definition - function getDefinitionAtPosition(fileName, position) { + function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly, stopAtAlias) { synchronizeHostData(); - return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); + return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias); } function getDefinitionAndBoundSpan(fileName, position) { synchronizeHostData(); @@ -164645,7 +165277,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -164669,17 +165301,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -164726,16 +165358,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -164751,7 +165383,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -164781,8 +165413,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -164791,8 +165423,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -164813,10 +165445,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -164913,7 +165545,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -164922,15 +165554,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -164940,12 +165572,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -165042,14 +165674,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -165059,7 +165691,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -165145,10 +165777,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -165163,12 +165795,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -165286,9 +165918,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -165444,14 +166076,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -165498,7 +166130,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -165513,16 +166145,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -165564,7 +166196,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -165611,7 +166243,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -165644,144 +166276,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.decorators); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -165793,14 +166425,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -165809,35 +166441,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -165846,21 +166478,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -165868,7 +166500,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -165898,7 +166530,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -165909,8 +166541,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if (variableDeclaration.initializer || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -165925,7 +166557,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -165950,8 +166582,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -165974,26 +166606,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -166018,21 +166650,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -166040,18 +166672,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -166059,25 +166691,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -166085,7 +166717,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -166101,7 +166733,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -166116,12 +166748,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -166130,21 +166762,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -166154,20 +166786,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -166175,7 +166807,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -166343,7 +166975,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -166433,13 +167065,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -166521,7 +167153,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -166537,43 +167169,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -166589,7 +167221,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -166598,7 +167230,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -166606,12 +167238,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -166620,7 +167252,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -166628,7 +167260,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -166637,7 +167269,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -166646,37 +167278,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, options); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -166684,23 +167316,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -166715,108 +167347,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -166866,11 +167498,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -166881,7 +167513,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -166893,7 +167525,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -166908,7 +167540,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -166930,7 +167562,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -167713,11 +168345,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -167764,7 +168396,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -167801,7 +168433,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -167942,9 +168574,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -167971,7 +168603,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 54cc1b14b5cc2..0bfa494a26252 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -89,7 +89,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "".concat(ts.versionMajorMinor, ".1-rc"); /* @internal */ var Comparison; (function (Comparison) { @@ -136,7 +136,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -828,9 +828,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -866,7 +866,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -920,27 +920,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1180,12 +1180,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1639,7 +1639,7 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ @@ -1730,7 +1730,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -1802,11 +1802,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -1824,7 +1824,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -1841,14 +1841,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -1879,13 +1879,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -1915,7 +1915,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -1976,9 +1976,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2097,24 +2097,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2124,7 +2124,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2180,7 +2180,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2280,12 +2280,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2416,7 +2416,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2495,7 +2495,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2503,12 +2503,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2518,26 +2518,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2568,42 +2568,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2624,7 +2624,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2645,7 +2645,7 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "" + result + (result ? "|" : "") + enumName; + result = "".concat(result).concat(result ? "|" : "").concat(enumName); remainingFlags &= ~enumValue; } } @@ -2742,20 +2742,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2794,7 +2794,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -2846,10 +2846,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -2858,35 +2858,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -2918,11 +2918,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -2954,7 +2954,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3001,10 +3001,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3118,9 +3118,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3135,11 +3135,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3168,11 +3168,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3189,7 +3189,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3406,7 +3406,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3704,7 +3704,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3716,11 +3716,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -3810,20 +3810,20 @@ var ts; } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -3859,7 +3859,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -3868,7 +3868,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -3876,7 +3876,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -3885,7 +3885,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -3895,7 +3895,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -3903,7 +3903,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -3912,7 +3912,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -3930,7 +3930,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4649,7 +4649,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; - NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -5266,10 +5265,11 @@ var ts; ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16"; ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var ModuleDetectionKind; @@ -5279,7 +5279,7 @@ var ts; */ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy"; /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto"; /** @@ -5324,8 +5324,8 @@ var ts; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + ModuleKind[ModuleKind["Node16"] = 100] = "Node16"; ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); var JsxEmit; @@ -5861,37 +5861,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -5963,7 +5963,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6180,7 +6180,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6432,7 +6432,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6445,7 +6445,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6461,7 +6461,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6484,7 +6484,7 @@ var ts; var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6579,7 +6579,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6634,7 +6634,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6666,7 +6666,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6921,7 +6921,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -6930,7 +6930,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -6946,7 +6946,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7048,7 +7048,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -7073,7 +7073,7 @@ var ts; } } if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -7089,7 +7089,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7240,8 +7240,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7253,10 +7253,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7320,8 +7320,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7344,7 +7344,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7431,16 +7431,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7454,18 +7454,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7485,7 +7485,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7562,7 +7562,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -7846,17 +7846,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -7873,7 +7873,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8247,6 +8247,7 @@ var ts; _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), + The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), @@ -8258,10 +8259,10 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), - Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."), Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), + This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -8276,7 +8277,7 @@ var ts; 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_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_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -8307,7 +8308,7 @@ var ts; await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -8359,7 +8360,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), - Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), @@ -8377,7 +8378,7 @@ var ts; Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), - Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."), + Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."), resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."), resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), @@ -8388,7 +8389,7 @@ var ts; An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), - auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."), + auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8397,7 +8398,8 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), - This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."), + The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -8648,7 +8650,6 @@ var ts; A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), - 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."), Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), 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."), @@ -8706,6 +8707,7 @@ var ts; _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."), Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."), + Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8861,6 +8863,7 @@ var ts; This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), @@ -8874,8 +8877,8 @@ var ts; Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."), Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), - Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"), Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), @@ -8986,6 +8989,7 @@ var ts; This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -9541,7 +9545,6 @@ var ts; This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), - JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -9851,100 +9854,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10033,16 +10036,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10071,17 +10074,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10106,7 +10109,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10184,18 +10187,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10209,50 +10212,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10266,29 +10269,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10299,10 +10302,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10312,24 +10315,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10337,7 +10340,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10361,8 +10364,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10373,18 +10376,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10445,12 +10448,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10460,20 +10463,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10484,7 +10487,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10509,7 +10512,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10564,17 +10567,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10593,7 +10596,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10616,15 +10619,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10679,8 +10682,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10704,7 +10707,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10714,15 +10717,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10735,7 +10738,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10747,10 +10750,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -10808,8 +10811,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10824,11 +10827,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -10838,7 +10841,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -10852,7 +10855,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10862,7 +10865,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -10870,7 +10873,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10883,7 +10886,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -10891,28 +10894,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -10920,10 +10923,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -10946,47 +10949,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -10994,29 +10997,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11024,14 +11027,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11064,7 +11067,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11080,7 +11083,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11090,7 +11093,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11108,11 +11111,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11121,7 +11124,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11140,14 +11143,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11158,8 +11161,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11174,101 +11177,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11277,98 +11280,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11381,20 +11384,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11402,7 +11405,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11414,18 +11417,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11433,10 +11436,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11444,10 +11447,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11455,175 +11458,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; - } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; + } + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11633,7 +11636,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11644,23 +11647,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11674,41 +11677,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11716,13 +11719,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11731,19 +11734,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11753,7 +11756,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11774,9 +11777,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11784,7 +11787,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -11798,42 +11801,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -11841,20 +11844,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -11877,7 +11880,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -11890,16 +11893,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11920,10 +11923,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -11935,86 +11938,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12089,9 +12092,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12157,23 +12160,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12381,9 +12384,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12391,7 +12394,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12421,14 +12424,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12542,7 +12545,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12560,7 +12563,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12571,7 +12574,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12601,30 +12604,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12659,42 +12662,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12987,16 +12990,16 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a @@ -13007,7 +13010,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13034,33 +13037,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13095,7 +13098,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13104,25 +13107,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13131,12 +13134,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13152,7 +13155,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13161,7 +13164,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13182,7 +13185,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13192,7 +13195,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13201,8 +13204,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13211,13 +13214,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13229,13 +13232,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13253,20 +13256,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13274,12 +13277,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13288,24 +13291,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13325,18 +13328,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13345,14 +13348,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13367,30 +13370,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13400,13 +13403,13 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13415,12 +13418,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13435,8 +13438,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13447,8 +13450,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13456,15 +13459,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13473,9 +13476,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13496,8 +13499,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13506,10 +13509,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13521,8 +13524,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13531,26 +13534,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13558,13 +13561,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13574,36 +13577,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13616,13 +13619,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13631,11 +13634,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13652,15 +13655,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13668,8 +13671,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13680,13 +13683,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13704,18 +13707,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13739,115 +13742,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13874,10 +13877,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -13891,76 +13894,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -13970,15 +13973,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14004,13 +14007,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14018,12 +14021,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14052,11 +14055,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion @@ -14097,7 +14100,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14258,11 +14261,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14293,28 +14296,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14325,16 +14328,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14349,7 +14352,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14402,7 +14405,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14436,7 +14439,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14468,9 +14471,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14482,13 +14485,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14497,7 +14500,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14505,10 +14508,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14519,7 +14522,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14530,7 +14533,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14691,62 +14694,62 @@ var ts; var _a; // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14761,21 +14764,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -14799,16 +14802,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -14820,9 +14823,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -14834,7 +14837,7 @@ var ts; } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isCommonJSContainingModuleKind(kind) { - return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext; } function isEffectiveExternalModule(node, compilerOptions) { return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); @@ -14846,10 +14849,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -14879,24 +14882,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -14906,9 +14909,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -14918,25 +14921,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -14946,25 +14949,29 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; } } ts.isAnyImportSyntax = isAnyImportSyntax; + function isAnyImportOrBareOrAccessedRequire(node) { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15005,19 +15012,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15032,21 +15039,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15136,7 +15143,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15150,7 +15157,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15159,29 +15166,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15213,36 +15220,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15251,12 +15258,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15275,24 +15282,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15301,48 +15308,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15351,40 +15358,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15409,23 +15416,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15435,23 +15442,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15474,10 +15481,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15487,12 +15494,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15500,14 +15507,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15519,21 +15526,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15544,13 +15551,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15561,7 +15568,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15569,30 +15576,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15654,14 +15661,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15676,9 +15683,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15689,27 +15696,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15722,17 +15729,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15756,9 +15763,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15780,28 +15787,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15817,21 +15824,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15840,8 +15847,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15849,34 +15856,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -15884,10 +15891,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15900,25 +15907,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -15934,11 +15941,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15954,9 +15961,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15964,64 +15971,64 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16031,49 +16038,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16081,10 +16088,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16092,7 +16099,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16105,7 +16112,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16117,11 +16124,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16129,7 +16136,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16137,15 +16144,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16171,7 +16178,7 @@ var ts; } ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { - if (node.kind === 203 /* BindingElement */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && @@ -16185,11 +16192,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16200,7 +16207,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16227,7 +16234,7 @@ var ts; * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16253,11 +16260,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16275,7 +16282,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16283,7 +16290,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16291,8 +16298,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16314,17 +16321,13 @@ var ts; if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - var nameOrArgument = getNameOrArgument(initializer); - if (ts.isPrivateIdentifier(nameOrArgument)) { - ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -16358,7 +16361,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16383,14 +16386,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16409,23 +16412,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16462,17 +16465,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16484,14 +16487,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16502,12 +16505,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16515,7 +16518,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16528,18 +16531,18 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { - var _a, _b, _c; + var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: - return node.initializer.arguments[0].text; - case 266 /* ImportDeclaration */: - return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: - return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + case 254 /* SyntaxKind.VariableDeclaration */: + return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; + case 266 /* SyntaxKind.ImportDeclaration */: + return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); } @@ -16551,14 +16554,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16568,17 +16571,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16586,11 +16589,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16598,7 +16601,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16619,13 +16622,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16639,7 +16642,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16649,27 +16652,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16681,7 +16684,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16696,11 +16699,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16729,13 +16732,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16746,7 +16749,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16770,7 +16773,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16836,7 +16839,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16853,41 +16856,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -16898,7 +16901,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -16907,22 +16910,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -16939,11 +16942,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16953,7 +16956,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -16962,18 +16965,18 @@ var ts; ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16994,13 +16997,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17011,13 +17014,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17026,7 +17029,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17034,27 +17037,30 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - // Any name in an export specifier or JSX Attribute + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + // Any name in an export specifier or JSX Attribute or Jsx Element return true; } return false; @@ -17070,36 +17076,44 @@ var ts; // export = // export default // module.exports = - // {} - // {name: } + // module.exports.x = + // const x = require("...") + // const { x } = require("...") + // const x = require("...").y + // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 297 /* ShorthandPropertyAssignment */ || - node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { + return true; + } + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) + && ts.isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17118,7 +17132,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17135,7 +17149,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17144,7 +17158,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17157,7 +17171,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17184,11 +17198,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17196,7 +17210,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17215,7 +17229,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17228,38 +17242,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17269,7 +17283,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17286,7 +17300,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17296,19 +17310,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17321,10 +17335,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17340,11 +17354,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17359,7 +17373,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17368,11 +17382,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17380,15 +17394,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17407,58 +17421,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17637,129 +17651,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17769,9 +17783,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -17886,9 +17900,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -17903,8 +17917,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -17934,13 +17948,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -17959,13 +17973,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -17982,6 +17996,10 @@ var ts; return indentStrings[1].length; } ts.getIndentSize = getIndentSize; + function isNightly() { + return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders"); + } + ts.isNightly = isNightly; function createTextWriter(newLine) { var output; var indent; @@ -18206,12 +18224,22 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; + /** + * This function is an inverse of `getDeclarationEmitExtensionForPath`. + */ + function getPossibleOriginalInputExtensionForExtension(path) { + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; + } + ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { return options.outFile || options.out; } @@ -18271,10 +18299,10 @@ var ts; return ts.combinePaths(newDirPath, sourceFilePath); } ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) { diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } ts.writeFile = writeFile; function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) { @@ -18337,7 +18365,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18347,11 +18375,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18362,10 +18390,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18385,10 +18413,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18437,7 +18465,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18554,7 +18582,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18629,7 +18657,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18641,11 +18669,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18662,23 +18690,23 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18690,16 +18718,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18724,22 +18752,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18759,14 +18787,14 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18778,22 +18806,22 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -18801,15 +18829,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -18817,7 +18845,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -18830,14 +18858,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -18849,8 +18877,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -18860,33 +18888,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18917,10 +18945,15 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfAccessExpression(node) { + return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { return ts.isQualifiedName(node.parent) && node.parent.right === node || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -18928,12 +18961,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -18949,7 +18982,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19120,9 +19153,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19265,8 +19298,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19290,32 +19323,32 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SyntaxKind.SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19324,11 +19357,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19343,47 +19376,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19453,9 +19486,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19466,11 +19499,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19517,44 +19550,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19562,7 +19595,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19572,31 +19605,66 @@ var ts; return expr; } ts.getLeftmostAccessExpression = getLeftmostAccessExpression; + function forEachNameInAccessChainWalkingLeft(name, action) { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + function walkAccessExpression(access) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { + if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { + var res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + // Chain interrupted by non-static-name access 'x[expr()].y.z' + return undefined; + } + } + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (ts.isIdentifier(access.expression)) { + // End of chain at Identifier 'x.y.z' + return action(access.expression); + } + // End of chain at non-Identifier 'x().y.z' + return undefined; + } + } + ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19630,9 +19698,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19641,8 +19709,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19650,8 +19718,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -19846,7 +19914,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -19855,43 +19923,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -19901,16 +19969,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -19919,7 +19987,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -19951,15 +20019,15 @@ var ts; file.externalModuleIndicator = ts.isFileProbablyExternalModule(file); }; case ts.ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } var combined_1 = ts.or.apply(void 0, checks); @@ -19970,15 +20038,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -19988,8 +20056,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -20014,7 +20082,7 @@ var ts; case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; default: @@ -20039,7 +20107,7 @@ var ts; return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return true; } @@ -20075,7 +20143,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20092,14 +20160,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20107,13 +20175,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20212,9 +20280,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20227,7 +20295,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20236,7 +20304,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20254,10 +20322,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20279,7 +20347,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20316,11 +20384,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20357,7 +20425,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20482,43 +20550,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20526,7 +20595,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20537,11 +20606,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20572,7 +20641,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20625,11 +20694,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20638,7 +20707,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20747,23 +20816,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20779,10 +20848,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -20817,7 +20886,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -20828,34 +20897,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20996,7 +21065,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21016,18 +21085,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return node.parent.decorators; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21035,45 +21104,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21085,7 +21154,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21103,7 +21172,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21112,7 +21181,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21151,7 +21220,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21171,42 +21240,47 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; + function getParameterTypeNode(parameter) { + var _a; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + } + ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); /* @internal */ var ts; @@ -21329,28 +21403,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21361,7 +21435,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21381,8 +21455,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21398,7 +21472,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21416,10 +21490,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21432,7 +21506,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21440,11 +21514,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21458,7 +21532,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21475,10 +21549,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21508,8 +21582,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21522,9 +21596,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21544,7 +21618,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21566,7 +21640,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21575,21 +21649,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21607,16 +21681,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21628,8 +21702,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21644,8 +21718,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21662,14 +21736,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21689,9 +21763,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21885,11 +21959,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -21947,10 +22021,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22081,12 +22155,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22242,18 +22316,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22289,30 +22363,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22380,38 +22454,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22515,11 +22589,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22537,7 +22611,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) { @@ -22548,7 +22622,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseSignatureDeclaration(updated, original) { @@ -22560,9 +22634,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateBaseFunctionLikeDeclaration(updated, original) { @@ -22596,7 +22670,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22609,21 +22683,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22632,7 +22706,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22643,19 +22717,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22665,10 +22739,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22687,8 +22761,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22700,9 +22774,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22712,25 +22786,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22738,9 +22812,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 8388608 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22750,51 +22824,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 33554432 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 8192 /* ContainsLexicalThis */; + transformFlags = 8192 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -22807,23 +22881,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -22835,34 +22909,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -22870,7 +22944,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -22887,12 +22961,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 65536 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 65536 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -22915,11 +22989,11 @@ var ts; name = modifiersOrName; constraint = nameOrConstraint; } - var node = createBaseNamedDeclaration(163 /* TypeParameter */, + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, /*decorators*/ undefined, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateTypeParameterDeclaration(node, modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { @@ -22945,22 +23019,22 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -22978,12 +23052,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 4096 /* ContainsTypeScriptClassSyntax */; + 1 /* TransformFlags.ContainsTypeScript */ | + 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; return node; } // @api @@ -22997,11 +23071,11 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23015,18 +23089,18 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 8388608 /* ContainsClassFields */; + 8388608 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23044,10 +23118,10 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23063,26 +23137,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -23102,11 +23176,11 @@ var ts; } // @api function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, decorators, modifiers, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 8388608 /* TransformFlags.ContainsClassFields */; return node; } // @api @@ -23119,11 +23193,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23137,7 +23211,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(172 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -23153,7 +23227,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(173 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -23169,11 +23243,11 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23186,11 +23260,11 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23203,10 +23277,10 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23220,10 +23294,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23242,11 +23316,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23259,10 +23333,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23274,11 +23348,11 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23300,10 +23374,10 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23334,10 +23408,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23349,9 +23423,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23362,9 +23436,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23375,9 +23449,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23388,12 +23462,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23407,9 +23481,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23420,9 +23494,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23434,7 +23508,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23444,7 +23518,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23452,7 +23526,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23460,12 +23534,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23479,9 +23553,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23492,10 +23566,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23506,22 +23580,22 @@ var ts; : node; } function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertion; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; + var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? qualifierOrAssertions : undefined; var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; @@ -23536,9 +23610,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23549,18 +23623,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23571,10 +23645,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23586,14 +23660,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23609,9 +23683,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23625,16 +23699,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23646,12 +23720,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23662,21 +23736,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 16384 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23698,7 +23772,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23717,7 +23791,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23731,7 +23805,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -23743,8 +23817,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23760,13 +23834,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -23776,7 +23850,7 @@ var ts; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -23787,7 +23861,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -23797,8 +23871,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23814,8 +23888,8 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); @@ -23823,12 +23897,12 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -23839,7 +23913,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -23848,13 +23922,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 4194304 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -23871,8 +23945,8 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); @@ -23882,18 +23956,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -23903,7 +23977,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -23911,9 +23985,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23927,7 +24001,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -23935,12 +24009,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23954,13 +24028,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23972,7 +24046,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -23985,23 +24059,23 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24019,15 +24093,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 8192 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24044,7 +24118,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24057,7 +24131,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24070,7 +24144,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24083,13 +24157,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24100,17 +24174,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24122,7 +24196,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24131,7 +24205,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24143,7 +24217,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24153,46 +24227,46 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) - return 32768 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return 32768 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 32768 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24200,7 +24274,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24212,11 +24286,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24238,13 +24312,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24255,8 +24329,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24282,41 +24356,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 524288 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 524288 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24328,12 +24402,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 16384 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 16384 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24344,8 +24418,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24361,17 +24435,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24383,13 +24457,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24401,11 +24475,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24419,33 +24493,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24463,13 +24537,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24481,8 +24555,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24490,7 +24564,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24504,12 +24578,12 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24522,11 +24596,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24539,7 +24613,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24559,7 +24633,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24576,7 +24650,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24593,7 +24667,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24616,7 +24690,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24636,7 +24710,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24646,9 +24720,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24662,11 +24736,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24677,11 +24751,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24692,13 +24766,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24709,7 +24783,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24726,7 +24800,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24743,7 +24817,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24760,7 +24834,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24773,7 +24847,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -24793,17 +24867,17 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24818,17 +24892,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 131072 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -24840,25 +24914,25 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 2097152 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } return node; @@ -24878,14 +24952,14 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -24903,9 +24977,9 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24921,9 +24995,9 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24938,12 +25012,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -24957,21 +25031,21 @@ var ts; } // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */, decorators, modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */, decorators, modifiers); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -24985,7 +25059,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -24998,7 +25072,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25011,10 +25085,10 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -25025,13 +25099,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -25046,14 +25120,14 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25068,7 +25142,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25076,9 +25150,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25091,10 +25165,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25106,10 +25180,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25121,7 +25195,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25135,10 +25209,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25149,12 +25223,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25165,10 +25239,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25179,14 +25253,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25199,13 +25273,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25218,7 +25292,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -25226,7 +25300,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25242,10 +25316,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25256,14 +25330,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25276,7 +25350,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */, + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -25286,10 +25360,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25344,7 +25418,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -25361,7 +25435,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25375,7 +25449,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25387,7 +25461,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25416,7 +25490,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25433,7 +25507,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25451,7 +25525,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25472,7 +25546,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25493,7 +25567,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25511,7 +25585,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25526,13 +25600,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25546,7 +25620,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25558,7 +25632,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25575,7 +25649,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25588,7 +25662,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25601,7 +25675,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25673,7 +25747,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -25685,7 +25759,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -25697,7 +25771,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -25714,7 +25788,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -25722,7 +25796,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25735,7 +25809,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25743,9 +25817,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25759,7 +25833,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25767,9 +25841,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25783,11 +25857,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25798,7 +25872,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -25806,7 +25880,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25819,10 +25893,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25834,25 +25908,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25864,11 +25938,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25879,11 +25953,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25894,13 +25968,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -25914,7 +25988,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -25931,7 +26005,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -25944,16 +26018,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -25968,7 +26042,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -25981,7 +26055,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -25996,7 +26070,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -26026,13 +26100,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -26058,12 +26132,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 32768 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 32768 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26077,13 +26151,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26098,7 +26172,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26115,7 +26189,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26154,7 +26228,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26169,7 +26243,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26187,28 +26261,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26219,7 +26293,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26227,7 +26301,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26242,7 +26316,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26256,12 +26330,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26284,7 +26358,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26301,7 +26375,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26312,14 +26386,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26341,12 +26415,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26460,11 +26534,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26490,7 +26564,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26511,20 +26585,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26532,7 +26606,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26541,11 +26615,11 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); } @@ -26612,9 +26686,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26633,7 +26707,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26646,7 +26720,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26659,7 +26733,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -26684,9 +26758,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -26703,7 +26777,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -26761,7 +26835,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -26950,52 +27024,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27004,14 +27078,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27020,22 +27094,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 33562624 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27047,78 +27121,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 589443072 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 557748224 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 591310848 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537165824 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 536940544 /* ClassExcludes */; - case 171 /* Constructor */: - return 591306752 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 570433536 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 574529536 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 536973312 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536903680 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536887296 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return 536887296 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return 589443072 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return 536870912 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return 557748224 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return 591310848 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return 537165824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return 536940544 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return 591306752 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return 570433536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return 574529536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return 536973312 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return 536903680 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return 536887296 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return 536870912 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return 536870912 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return 536870912 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27128,7 +27202,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27191,50 +27265,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27262,22 +27336,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27305,7 +27379,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27374,7 +27448,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27416,7 +27490,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27425,7 +27499,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27457,7 +27531,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -27693,7 +27767,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -27716,8 +27790,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -27758,7 +27832,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -27793,7 +27867,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -27809,7 +27883,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -27863,13 +27937,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -27882,7 +27956,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -27972,13 +28046,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28385,7 +28459,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28394,741 +28468,741 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29136,176 +29210,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29325,7 +29399,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29504,14 +29578,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29550,7 +29624,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29575,14 +29649,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29590,7 +29664,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29619,8 +29693,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29636,26 +29710,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29663,7 +29737,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -29725,7 +29799,7 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -29770,10 +29844,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -29892,7 +29966,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -29904,11 +29978,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -29940,12 +30014,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -29963,7 +30037,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -29978,7 +30052,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -29993,7 +30067,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30008,21 +30082,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30043,29 +30117,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30076,68 +30150,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30145,21 +30219,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30292,7 +30366,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30373,7 +30447,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30393,9 +30467,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30407,14 +30481,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 93 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30426,7 +30500,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30442,20 +30516,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30463,9 +30537,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -30473,7 +30547,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30481,51 +30555,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.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 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30537,345 +30611,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.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 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -30884,64 +30958,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -30990,7 +31064,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31015,13 +31089,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31069,7 +31143,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31097,8 +31171,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31120,7 +31194,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31218,7 +31292,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31237,25 +31311,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31263,28 +31337,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31302,7 +31376,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31311,10 +31385,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31351,15 +31425,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31391,13 +31465,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31430,7 +31504,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31458,12 +31532,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31481,7 +31555,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31501,8 +31575,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31543,7 +31617,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -31570,16 +31644,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -31620,52 +31694,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -31766,15 +31840,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -31786,7 +31860,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -31794,31 +31868,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -31856,7 +31930,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -31871,17 +31945,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -31891,7 +31965,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -31916,24 +31990,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -31944,7 +32018,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32011,24 +32085,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32045,7 +32119,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32057,11 +32131,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32085,23 +32159,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32114,23 +32188,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32143,12 +32217,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32176,23 +32250,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32200,9 +32274,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32213,18 +32287,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32233,50 +32307,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32288,42 +32362,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32332,7 +32406,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32349,8 +32423,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32365,51 +32439,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32429,7 +32503,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32437,7 +32511,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32503,7 +32577,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32526,38 +32600,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -32604,20 +32678,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -32626,8 +32700,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -32636,58 +32710,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -32708,7 +32782,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -32726,39 +32800,39 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` } } @@ -32773,11 +32847,12 @@ var ts; var startPos = scanner.getStartPos(); var result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -32787,13 +32862,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -32822,7 +32897,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -32840,18 +32915,18 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) { + function parseEntityName(allowReservedWords, diagnosticMessage) { var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; } dotPos = getNodePos(); - entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos); + entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos); } return entity; } @@ -32884,12 +32959,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -32900,7 +32975,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -32918,7 +32993,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -32926,13 +33001,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -32947,30 +33022,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -32984,11 +33059,11 @@ var ts; } // TYPES function parseEntityNameOfTypeReference() { - return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected); + return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -32998,14 +33073,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33043,12 +33118,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33060,8 +33135,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33069,9 +33144,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*decorators*/ undefined, @@ -33085,15 +33160,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33102,13 +33177,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33116,9 +33191,10 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); - var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true); - var typeArguments = tryParseTypeArguments(); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); + var entityName = parseEntityName(/*allowReservedWords*/ true); + // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. + var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } function parseTypeParameter() { @@ -33127,7 +33203,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33146,21 +33222,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33184,7 +33260,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33200,7 +33276,7 @@ var ts; // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), @@ -33214,11 +33290,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33228,16 +33304,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33259,11 +33335,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33282,17 +33358,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33301,20 +33377,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33334,7 +33410,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33353,21 +33429,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(decorators, modifiers, parameters, type); @@ -33375,14 +33451,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33391,7 +33467,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33399,10 +33475,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33412,7 +33488,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33423,30 +33499,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33455,16 +33531,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33475,9 +33551,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33486,51 +33562,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33543,10 +33619,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -33555,10 +33631,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33567,21 +33643,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33590,10 +33666,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -33603,34 +33679,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -33639,89 +33715,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -33729,48 +33805,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -33780,18 +33856,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -33799,15 +33875,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -33823,9 +33899,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -33839,17 +33915,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -33878,7 +33954,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -33892,35 +33968,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -33930,7 +34006,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -33938,17 +34014,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -33969,65 +34045,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34038,19 +34114,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34068,10 +34144,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34084,10 +34160,10 @@ var ts; setDecoratorContext(/*val*/ false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos); + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -34095,9 +34171,9 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) { + function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -34123,7 +34199,7 @@ var ts; // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -34137,12 +34213,12 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then @@ -34151,13 +34227,13 @@ var ts; // Note: we call reScanGreaterToken so that we get an appropriately merged token // for cases like `> > =` becoming `>>=` if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } // It wasn't an assignment or a lambda. This is a conditional expression: return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34193,8 +34269,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher()), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34202,8 +34278,8 @@ var ts; return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, disallowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -34213,14 +34289,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34228,53 +34304,53 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? - parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) : - tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); }); + return triState === 1 /* Tristate.True */ ? + parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } // True -> We definitely expect a parenthesized arrow function here. // False -> There *cannot* be a parenthesized arrow function here. // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34283,102 +34359,102 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - return 1 /* True */; + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function parsePossibleParenthesizedArrowFunctionExpression() { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction); + var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction) { + function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - return parseSimpleArrowFunctionExpression(pos, expr, disallowReturnTypeInArrowFunction, asyncModifier); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); } } return undefined; @@ -34387,26 +34463,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity, disallowReturnTypeInArrowFunction) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34416,7 +34492,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34433,28 +34509,11 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - // Given: - // x ? y => ({ y }) : z => ({ z }) - // We try to parse the body of the first arrow function by looking at: - // ({ y }) : z => ({ z }) - // This is a valid arrow function with "z" as the return type. - // - // But, if we're in the true side of a conditional expression, this colon - // terminates the expression, so we cannot allow a return type if we aren't - // certain whether or not the preceding text was parsed as a parameter list. - // - // For example, - // a() ? (b: number, c?: string): void => d() : e - // is determined by isParenthesizedArrowFunctionExpression to unambiguously - // be an arrow expression, so we allow a return type. - if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) { - return undefined; - } - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34469,31 +34528,31 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) : parseIdentifier(); var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync, disallowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + function parseArrowFunctionExpressionBody(isAsync) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34510,28 +34569,28 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }) - : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction); }); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } function parseConditionalExpressionRest(leftOperand, pos) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher() + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -34539,7 +34598,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -34568,16 +34627,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -34598,7 +34657,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -34626,7 +34685,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -34659,7 +34718,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -34676,10 +34735,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -34704,23 +34763,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -34743,18 +34802,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -34775,17 +34834,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -34826,29 +34885,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -34910,19 +34969,19 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -34930,11 +34989,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -34960,11 +35019,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -34975,11 +35034,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -34989,13 +35048,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35009,15 +35068,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35027,14 +35086,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35046,21 +35105,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35068,8 +35127,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35090,60 +35149,60 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : - scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* SyntaxKind.EqualsToken */ ? undefined : + scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35156,11 +35215,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35173,36 +35232,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35223,8 +35282,8 @@ var ts; } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35233,7 +35292,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35244,30 +35303,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35282,14 +35341,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35298,7 +35357,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35306,9 +35365,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35321,7 +35380,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35329,22 +35388,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(31 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35357,58 +35416,34 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` - // These tokens can't follow in a call expression, nor can they start an - // expression. So, consider the type argument list part of an instantiation - // expression. - // falls through - case 27 /* CommaToken */: // foo, - case 24 /* DotToken */: // foo. - case 28 /* QuestionDotToken */: // foo?. - case 21 /* CloseParenToken */: // foo) - case 23 /* CloseBracketToken */: // foo] - case 58 /* ColonToken */: // foo: - case 26 /* SemicolonToken */: // foo; - case 57 /* QuestionToken */: // foo? - case 34 /* EqualsEqualsToken */: // foo == - case 36 /* EqualsEqualsEqualsToken */: // foo === - case 35 /* ExclamationEqualsToken */: // foo != - case 37 /* ExclamationEqualsEqualsToken */: // foo !== - case 55 /* AmpersandAmpersandToken */: // foo && - case 56 /* BarBarToken */: // foo || - case 60 /* QuestionQuestionToken */: // foo ?? - case 52 /* CaretToken */: // foo ^ - case 50 /* AmpersandToken */: // foo & - case 51 /* BarToken */: // foo | - case 19 /* CloseBraceToken */: // foo } - case 1 /* EndOfFileToken */: // foo + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; } - // Treat anything else as an expression. - return false; + // Consider something a type argument list only if the following token can't start an expression. + return !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35416,21 +35451,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35438,21 +35473,21 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); + var expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -35460,34 +35495,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { + var expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35496,18 +35531,18 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); - var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }) : undefined; + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); + var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful. node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); - var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); + parseExpected(58 /* SyntaxKind.ColonToken */); + var initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker @@ -35520,10 +35555,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35537,17 +35572,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -35558,20 +35593,20 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -35579,13 +35614,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -35598,9 +35633,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -35609,7 +35644,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -35621,58 +35656,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -35680,26 +35715,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { - var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); }); - parseExpected(21 /* CloseParenToken */); + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { + var expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35707,10 +35742,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35718,7 +35753,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -35726,47 +35761,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -35775,7 +35810,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -35795,25 +35830,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -35825,7 +35860,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -35836,9 +35871,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -35859,25 +35894,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -35900,44 +35935,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -35950,51 +35985,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36004,7 +36039,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36013,68 +36048,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36083,7 +36118,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -36106,16 +36141,16 @@ var ts; if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { var node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -36124,33 +36159,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36159,7 +36194,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36170,10 +36205,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* SyntaxKind.OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -36182,26 +36217,26 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36209,29 +36244,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36244,8 +36279,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36257,13 +36292,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36279,19 +36314,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36304,27 +36339,27 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36335,9 +36370,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); // Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker. node.typeParameters = typeParameters; @@ -36347,11 +36382,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36359,20 +36394,20 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); @@ -36380,21 +36415,21 @@ var ts; function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 173 /* SetAccessor */) + if (type && node.kind === 173 /* SyntaxKind.SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36411,7 +36446,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36421,24 +36456,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36452,7 +36487,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); } @@ -36467,7 +36502,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36480,7 +36515,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36497,17 +36532,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -36528,7 +36563,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -36536,33 +36571,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -36574,17 +36609,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36592,21 +36627,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -36614,17 +36649,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36640,45 +36675,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -36687,11 +36722,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36708,12 +36743,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -36724,9 +36759,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -36736,10 +36771,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36747,17 +36782,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -36768,37 +36803,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -36808,7 +36843,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -36816,7 +36851,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -36830,15 +36865,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -36847,21 +36882,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); - var value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -36875,15 +36910,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -36901,26 +36936,26 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -36936,8 +36971,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -36950,17 +36985,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -36985,10 +37020,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37023,15 +37058,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37051,26 +37086,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37082,13 +37117,13 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } - var expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -37132,11 +37167,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37148,10 +37183,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37160,16 +37195,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); - var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); - while (token() === 80 /* PrivateIdentifier */) { + var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37177,9 +37212,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37189,9 +37224,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37239,7 +37274,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37252,16 +37287,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37269,35 +37304,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37305,10 +37340,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37327,7 +37362,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37356,26 +37391,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37383,14 +37418,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37398,7 +37433,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37447,7 +37482,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37485,7 +37520,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37500,31 +37535,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -37536,8 +37571,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37551,32 +37586,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -37593,7 +37628,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -37605,17 +37640,17 @@ var ts; // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false) + ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -37626,8 +37661,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -37655,35 +37690,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -37699,12 +37734,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -37715,12 +37750,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -37741,8 +37776,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -37764,14 +37799,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -37790,21 +37825,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -37838,7 +37873,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -37855,7 +37890,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -37879,11 +37914,11 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -37895,7 +37930,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -37906,9 +37941,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -37917,7 +37952,8 @@ var ts; if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + var end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -37932,18 +37968,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -37951,26 +37987,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -37978,15 +38014,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -37998,7 +38034,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38006,9 +38042,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38025,7 +38061,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38040,7 +38076,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38053,16 +38089,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38070,7 +38106,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38087,7 +38123,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38242,9 +38278,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38499,7 +38535,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -38514,7 +38550,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -38552,7 +38588,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -38605,7 +38641,7 @@ var ts; })(IncrementalParser || (IncrementalParser = {})); /** @internal */ function isDeclarationFileName(fileName) { - return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]); + return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions); } ts.isDeclarationFileName = isDeclarationFileName; function parseResolutionMode(mode, pos, end, reportDiagnostic) { @@ -38732,18 +38768,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -38777,15 +38813,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -38828,10 +38864,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -38851,11 +38887,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -38926,6 +38962,7 @@ var ts; ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -39158,18 +39195,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39178,7 +39215,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; var commandOptionsWithoutBuild = [ // CommandLine only options @@ -39261,7 +39298,7 @@ var ts; es2020: ts.ModuleKind.ES2020, es2022: ts.ModuleKind.ES2022, esnext: ts.ModuleKind.ESNext, - node12: ts.ModuleKind.Node12, + node16: ts.ModuleKind.Node16, nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -39436,15 +39473,15 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -39615,7 +39652,7 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, - node12: ts.ModuleResolutionKind.Node12, + node16: ts.ModuleResolutionKind.Node16, nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -39858,8 +39895,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, @@ -40091,7 +40128,7 @@ var ts; affectsModuleResolution: true, description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: ts.Diagnostics.Language_and_Environment, - defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; /* @internal */ @@ -40212,7 +40249,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40237,8 +40274,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40297,11 +40334,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40330,14 +40367,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40348,7 +40385,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -40683,7 +40720,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -40723,7 +40760,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -40790,16 +40827,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -40814,16 +40851,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -40840,7 +40877,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41032,10 +41069,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41086,19 +41123,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41107,25 +41144,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41180,7 +41217,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -41525,8 +41562,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -41767,11 +41804,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -41915,7 +41952,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -41949,13 +41986,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -41978,7 +42015,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42056,7 +42093,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42113,7 +42150,8 @@ var ts; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; - Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; + Extensions[Extensions["TsOnly"] = 5] = "TsOnly"; })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -42123,7 +42161,7 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { var _a; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -42131,7 +42169,8 @@ var ts; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations: failedLookupLocations + failedLookupLocations: failedLookupLocations, + resolutionDiagnostics: diagnostics }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -42208,7 +42247,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42271,7 +42310,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -42326,13 +42365,24 @@ var ts; // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions }; + var diagnostics = []; + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -42351,7 +42401,7 @@ var ts; isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); @@ -42417,7 +42467,7 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getDefaultNodeResolutionFeatures(options) { - return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -42434,6 +42484,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ts.emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: ts.noop }; return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { @@ -42476,7 +42528,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -42627,7 +42679,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -42662,7 +42714,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -42775,8 +42827,8 @@ var ts; case ts.ModuleKind.CommonJS: moduleResolution = ts.ModuleResolutionKind.NodeJs; break; - case ts.ModuleKind.Node12: - moduleResolution = ts.ModuleResolutionKind.Node12; + case ts.ModuleKind.Node16: + moduleResolution = ts.ModuleResolutionKind.Node16; break; case ts.ModuleKind.NodeNext: moduleResolution = ts.ModuleResolutionKind.NodeNext; @@ -42796,8 +42848,8 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ts.ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ts.ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ts.ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -42809,10 +42861,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43015,7 +43067,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43031,15 +43083,15 @@ var ts; // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; - NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default"; + NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default"; NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault"; NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); - function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { - return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); } function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -43058,15 +43110,34 @@ var ts; return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + var extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) + extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) + extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). + var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + var diagnostics = []; var state = { compilerOptions: compilerOptions, host: host, @@ -43074,10 +43145,12 @@ var ts; failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions: conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -43137,7 +43210,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43204,7 +43277,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43223,7 +43296,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43240,7 +43313,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43250,9 +43323,9 @@ var ts; } } function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) { var result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; + return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } @@ -43268,53 +43341,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: + case Extensions.TsOnly: + var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43373,6 +43448,8 @@ var ts; packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features: features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: ts.noop }; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); @@ -43459,6 +43536,8 @@ var ts; packageJsonInfoCache: packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: ts.noop }; var parts = ts.getPathComponents(fileName); parts.pop(); @@ -43522,6 +43601,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -43594,14 +43674,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; + case Extensions.TsOnly: + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -43638,7 +43720,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -43747,7 +43829,6 @@ var ts; function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { return loadModuleFromTargetImportOrExport; function loadModuleFromTargetImportOrExport(target, subpath, pattern) { - var _a, _b; if (typeof target === "string") { if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { if (state.traceEnabled) { @@ -43784,13 +43865,16 @@ var ts; } return toSearchResult(/*value*/ undefined); } - var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) + return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); } else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null if (!Array.isArray(target)) { - for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { - var key = _c[_i]; + for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) { + var key = _a[_i]; if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { var subTarget = target[key]; var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); @@ -43808,8 +43892,8 @@ var ts; } return toSearchResult(/*value*/ undefined); } - for (var _d = 0, target_2 = target; _d < target_2.length; _d++) { - var elem = target_2[_d]; + for (var _b = 0, target_2 = target; _b < target_2.length; _b++) { + var elem = target_2[_b]; var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); if (result) { return result; @@ -43827,6 +43911,128 @@ var ts; trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(/*value*/ undefined); + function toAbsolutePath(path) { + var _a, _b; + if (path === undefined) + return path; + return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a))); + } + function combineDirectoryPath(root, dir) { + return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir)); + } + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) { + var _a, _b, _c, _d; + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames }); + var commonSourceDirGuesses = []; + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory + var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts")); + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + var fragment = ts.ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + var parts = ts.getPathComponents(fragment); + parts.pop(); // remove a directory + var commonDir_1 = ts.getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir_1); + fragment = ts.ensureTrailingDirectorySeparator(commonDir_1); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(ts.createCompilerDiagnostic(isImports + ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath)); + } + for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) { + var commonSourceDirGuess = commonSourceDirGuesses_1[_i]; + var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) { + var candidateDir = candidateDirectories_1[_e]; + if (ts.startsWith(finalPath, candidateDir)) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator + var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; + for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { + var ext = jsAndDtsExtensions_1[_f]; + if (ts.fileExtensionIs(possibleInputBase, ext)) { + var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) { + var possibleExt = inputExts_1[_g]; + var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state))); + } + } + } + } + } + } + } + } + return undefined; + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) { + var _a, _b; + // Config file ouput paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess; + var candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } /* @internal */ @@ -43974,7 +44180,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44017,11 +44223,12 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -44064,9 +44271,10 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var diagnostics = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; /** @@ -44092,14 +44300,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44110,34 +44318,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44145,21 +44353,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44167,16 +44375,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -44196,7 +44404,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -44207,7 +44415,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -44281,8 +44489,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -44304,7 +44512,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -44331,7 +44539,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -44351,33 +44559,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -44403,36 +44611,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(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; @@ -44451,14 +44659,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -44485,11 +44693,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -44501,20 +44709,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -44534,7 +44742,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -44542,9 +44750,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -44557,7 +44765,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -44571,9 +44779,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -44597,11 +44805,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -44628,7 +44836,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -44661,21 +44869,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -44683,22 +44891,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -44706,21 +44914,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -44734,10 +44942,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -44747,8 +44955,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -44771,59 +44979,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -44833,47 +45041,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -44887,22 +45095,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -44910,7 +45118,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -44926,7 +45134,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -44937,68 +45145,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45010,7 +45218,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45022,7 +45230,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45037,28 +45245,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45068,7 +45276,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45087,8 +45295,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45102,7 +45310,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45153,12 +45361,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45180,7 +45388,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -45197,7 +45405,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -45268,7 +45476,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -45302,7 +45510,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -45331,7 +45539,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -45350,9 +45558,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -45376,7 +45584,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -45385,12 +45593,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -45398,16 +45606,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -45415,7 +45623,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -45426,15 +45634,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -45444,14 +45652,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -45500,9 +45708,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -45519,7 +45727,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -45533,7 +45741,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -45544,10 +45752,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -45572,7 +45780,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -45600,7 +45808,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -45629,7 +45837,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -45641,28 +45849,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -45688,8 +45896,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -45727,76 +45935,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -45813,9 +46021,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -45829,46 +46037,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -45895,17 +46103,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -45913,25 +46121,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -45939,8 +46147,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -45950,10 +46158,10 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } @@ -45967,7 +46175,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */ || prop.name.kind !== 79 /* SyntaxKind.Identifier */) { continue; } var identifier = prop.name; @@ -45979,9 +46187,9 @@ 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 === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; + var currentKind = prop.kind === 296 /* SyntaxKind.PropertyAssignment */ || prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || prop.kind === 169 /* SyntaxKind.MethodDeclaration */ + ? 1 /* ElementKind.Property */ + : 2 /* ElementKind.Accessor */; var existingKind = seen.get(identifier.escapedText); if (!existingKind) { seen.set(identifier.escapedText, currentKind); @@ -45989,17 +46197,17 @@ var ts; } } } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46007,10 +46215,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46036,9 +46244,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46049,8 +46257,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46058,29 +46266,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46098,24 +46306,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46157,7 +46365,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46168,7 +46376,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -46207,10 +46415,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -46220,7 +46428,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -46236,7 +46444,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -46249,7 +46457,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -46307,11 +46515,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -46321,7 +46529,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -46369,7 +46577,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -46378,28 +46586,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -46411,28 +46619,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -46443,94 +46651,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -46540,73 +46748,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -46617,27 +46825,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -46657,28 +46865,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -46697,13 +46905,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -46714,15 +46922,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -46743,13 +46951,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -46761,11 +46969,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -46779,17 +46987,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -46798,19 +47006,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -46818,7 +47026,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -46827,10 +47035,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -46849,7 +47057,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -46870,7 +47078,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -46882,7 +47090,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -46895,7 +47103,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -46913,13 +47121,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -46933,7 +47141,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -46945,12 +47153,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -46960,27 +47168,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -46999,7 +47207,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47014,7 +47222,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47059,12 +47267,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47080,7 +47288,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47093,19 +47301,19 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47117,72 +47325,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -47196,45 +47404,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -47248,9 +47456,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -47274,17 +47482,17 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } @@ -47369,32 +47577,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -47483,7 +47691,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -47617,24 +47825,24 @@ var ts; TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = new ts.Map(ts.getEntries({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ + string: 1 /* TypeFacts.TypeofEQString */, + number: 2 /* TypeFacts.TypeofEQNumber */, + bigint: 4 /* TypeFacts.TypeofEQBigInt */, + boolean: 8 /* TypeFacts.TypeofEQBoolean */, + symbol: 16 /* TypeFacts.TypeofEQSymbol */, + undefined: 65536 /* TypeFacts.EQUndefined */, + object: 32 /* TypeFacts.TypeofEQObject */, + function: 64 /* TypeFacts.TypeofEQFunction */ })); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -47740,10 +47948,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -47768,8 +47976,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -47784,7 +47992,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -47818,7 +48026,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -47832,20 +48040,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -47897,10 +48105,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -47995,7 +48203,7 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); @@ -48016,13 +48224,13 @@ var ts; getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48108,7 +48316,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48145,10 +48353,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -48219,32 +48427,32 @@ var ts; var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var nonInferrableAnyType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 65536 /* ObjectFlags.ContainsWideningType */); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -48254,27 +48462,28 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonInferrableType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48282,7 +48491,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -48290,11 +48499,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -48442,7 +48651,7 @@ var ts; var enumRelation = new ts.Map(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -48453,7 +48662,7 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; @@ -48599,7 +48808,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -48613,44 +48822,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -48682,13 +48891,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -48696,7 +48905,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -48719,7 +48928,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -48728,8 +48937,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -48740,9 +48949,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -48785,7 +48994,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -48827,7 +49036,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -48836,7 +49045,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -48851,9 +49060,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -48886,7 +49095,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -48896,17 +49105,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -48926,8 +49135,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -48941,7 +49150,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -48955,17 +49164,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -48979,7 +49188,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -48995,19 +49204,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49022,9 +49231,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49052,7 +49261,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49067,7 +49276,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49090,19 +49299,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49127,7 +49336,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49142,30 +49351,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -49218,35 +49427,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -49261,17 +49470,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -49291,13 +49500,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -49306,12 +49515,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -49321,20 +49530,20 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -49349,7 +49558,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -49357,11 +49566,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -49377,39 +49586,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -49417,7 +49626,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -49426,7 +49635,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -49441,20 +49650,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -49462,7 +49671,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -49470,8 +49679,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -49496,7 +49705,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -49533,7 +49742,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -49560,7 +49769,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -49583,22 +49792,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -49610,10 +49819,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -49627,31 +49836,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -49664,7 +49873,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -49708,7 +49917,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -49720,10 +49929,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -49733,9 +49942,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -49754,9 +49963,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -49767,20 +49976,20 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -49802,7 +50011,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -49819,15 +50028,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -49837,29 +50046,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -49880,13 +50089,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -49911,22 +50120,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { @@ -49940,7 +50149,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -49953,7 +50162,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -49965,14 +50174,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -49982,7 +50191,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -49999,7 +50208,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50031,7 +50240,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50039,7 +50248,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50067,12 +50276,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50116,7 +50325,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50131,7 +50340,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50139,7 +50348,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50155,7 +50364,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50164,7 +50373,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -50173,7 +50382,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -50194,7 +50403,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -50211,7 +50420,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -50291,7 +50500,7 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -50303,7 +50512,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -50311,31 +50520,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -50346,38 +50555,38 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol) { var links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } return undefined; @@ -50420,7 +50629,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -50428,7 +50637,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -50439,7 +50648,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -50460,7 +50669,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -50483,22 +50692,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -50508,7 +50717,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -50529,9 +50738,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -50539,9 +50748,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -50575,7 +50784,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -50583,8 +50792,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -50598,8 +50807,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -50619,7 +50828,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -50640,7 +50849,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -50671,7 +50880,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -50731,7 +50940,7 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; @@ -50740,9 +50949,6 @@ var ts; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) { - error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -50795,7 +51001,7 @@ var ts; var tsExtension = ts.tryExtractTSExtension(moduleReference); var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 || moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -50806,27 +51012,27 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); var suggestedExt = (_h = suggestedExtensions.find(function (_a) { var actualExt = _a[0], _importExt = _a[1]; return host.fileExists(absoluteRef_1 + actualExt); })) === null || _h === void 0 ? void 0 : _h[1]; if (suggestedExt) { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -50858,27 +51064,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -50892,7 +51098,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -50911,12 +51117,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -50948,7 +51154,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51000,15 +51206,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51023,7 +51229,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51058,7 +51264,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51147,21 +51353,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -51185,7 +51391,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -51206,7 +51412,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -51214,7 +51420,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -51224,7 +51430,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -51248,16 +51454,16 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol)); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && !getTypeOnlyAliasDeclaration(symbol)); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -51280,7 +51486,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -51294,7 +51500,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -51304,11 +51510,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -51340,14 +51546,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -51365,12 +51571,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -51379,9 +51585,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -51392,7 +51598,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -51411,7 +51617,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -51422,7 +51628,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -51466,9 +51672,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -51476,7 +51682,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -51520,7 +51726,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -51535,10 +51741,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -51549,16 +51755,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -51588,7 +51794,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -51612,14 +51818,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -51648,7 +51854,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -51657,28 +51863,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -51686,24 +51892,24 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + else if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement && ts.isVariableDeclaration(declaration.parent.parent) && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); @@ -51727,83 +51933,83 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -51811,7 +52017,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -51829,17 +52035,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 814775659 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -51873,12 +52079,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -51900,7 +52106,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -51935,62 +52141,62 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52004,66 +52210,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52073,19 +52279,19 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52102,8 +52308,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52111,43 +52317,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52155,39 +52361,63 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); + var name = typeParameterToName(newParam, context); + var newTypeVariable = ts.factory.createTypeReferenceNode(name); + context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var saveInferTypeParameters_1 = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters_1; + var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive + // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType + // inner conditional runs the check the user provided on the check type (distributively) and returns the result + // checkType extends infer T ? T extends checkType ? T extends extendsType ? trueType : falseType : never : never; + // this is potentially simplifiable to + // checkType extends infer T ? T extends checkType & extendsType ? trueType : falseType : never; + // but that may confuse users who read the output more. + // On the other hand, + // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; + // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); + } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -52198,7 +52428,7 @@ var ts; return typeToTypeNodeHelper(type, context); } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -52206,27 +52436,27 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -52235,16 +52465,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */ && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -52253,7 +52483,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -52269,26 +52499,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -52300,7 +52530,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -52359,20 +52589,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -52381,8 +52611,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -52394,27 +52624,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -52422,7 +52652,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -52430,23 +52660,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -52470,8 +52700,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -52483,8 +52713,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -52548,17 +52778,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -52568,16 +52798,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -52588,10 +52818,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -52601,19 +52831,19 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; - if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { + if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* CheckFlags.Late */ && isLateBoundName(propertySymbol.escapedName)) { if (propertySymbol.declarations) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { @@ -52636,12 +52866,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -52655,12 +52885,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -52669,11 +52899,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -52692,12 +52922,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -52706,7 +52936,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -52731,7 +52961,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -52766,22 +52996,22 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -52789,7 +53019,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); var thisParameter = tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); @@ -52797,11 +53027,11 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -52812,28 +53042,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -52857,7 +53087,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -52871,29 +53101,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */); - } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -52913,7 +53140,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -52922,9 +53149,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -52934,8 +53161,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -52945,7 +53172,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -52964,8 +53191,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -52984,7 +53211,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53014,7 +53241,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53029,11 +53256,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53053,11 +53280,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53109,7 +53336,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53117,8 +53344,8 @@ var ts; return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier; } 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 - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53127,7 +53354,7 @@ var ts; var targetFile = ts.getSourceFileOfModule(chain[0]); var specifier = void 0; var assertion = void 0; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) { specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext); @@ -53139,9 +53366,9 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; - if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -53200,16 +53427,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -53228,7 +53455,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -53240,7 +53467,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -53253,9 +53480,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -53264,23 +53491,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -53297,7 +53524,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -53305,13 +53532,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -53323,38 +53550,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -53383,7 +53610,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -53393,8 +53620,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -53428,7 +53655,7 @@ var ts; return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -53440,7 +53667,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_6) { return result_6; @@ -53449,20 +53676,30 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; return result; } + function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { + var typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; + } + return false; + } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -53481,20 +53718,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -53512,17 +53749,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -53536,11 +53773,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -53557,16 +53794,16 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -53575,7 +53812,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -53590,17 +53827,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -53631,8 +53868,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -53645,10 +53882,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -53663,16 +53900,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -53689,7 +53926,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -53705,9 +53942,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -53803,11 +54040,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -53860,37 +54097,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -53902,21 +54139,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -53928,14 +54165,14 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -53961,7 +54198,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -53969,11 +54206,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -53986,20 +54223,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54008,18 +54245,18 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54032,7 +54269,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54046,23 +54283,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54078,14 +54315,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54096,10 +54333,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); @@ -54108,7 +54345,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54121,7 +54358,7 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); @@ -54129,7 +54366,7 @@ var ts; var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -54145,12 +54382,12 @@ var ts; })))]); addResult(ts.factory.createModuleDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { addResult(ts.factory.createEnumDeclaration( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -54162,22 +54399,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -54211,7 +54448,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -54232,15 +54469,15 @@ var ts; var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -54289,7 +54526,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -54316,17 +54553,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -54369,15 +54606,15 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -54385,19 +54622,19 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -54408,7 +54645,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, @@ -54417,30 +54654,30 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -54448,21 +54685,21 @@ var ts; // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -54471,9 +54708,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -54481,16 +54718,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -54505,18 +54742,18 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -54531,7 +54768,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -54545,7 +54782,7 @@ var ts; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -54561,7 +54798,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -54576,17 +54813,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -54606,11 +54843,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -54621,25 +54858,25 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*decorators*/ undefined, @@ -54648,8 +54885,8 @@ var ts; /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); @@ -54658,19 +54895,19 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -54680,7 +54917,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -54689,7 +54926,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -54697,13 +54934,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -54724,7 +54961,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -54760,15 +54997,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -54778,22 +55015,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -54811,7 +55048,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -54820,17 +55057,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -54849,14 +55086,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -54866,10 +55103,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -54881,25 +55118,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -54907,27 +55144,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -54939,9 +55176,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -54955,9 +55192,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -54970,17 +55207,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -54997,84 +55234,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55083,11 +55320,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55111,7 +55348,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55160,23 +55397,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -55193,12 +55430,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -55223,28 +55460,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -55252,9 +55489,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -55269,7 +55506,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -55284,15 +55521,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -55328,34 +55565,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -55366,18 +55603,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -55394,7 +55631,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -55402,7 +55639,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -55414,7 +55651,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -55428,9 +55665,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 32768 /* TypeFlags.Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -55441,11 +55678,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -55456,11 +55693,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -55482,11 +55719,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -55498,8 +55735,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -55517,7 +55754,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -55540,14 +55777,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -55576,7 +55813,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -55598,7 +55835,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -55658,7 +55895,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -55697,7 +55934,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -55727,12 +55964,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -55756,7 +55993,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -55812,13 +56049,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -55830,7 +56067,7 @@ var ts; var _a; var exportedMember = members_4.get(name); if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -55863,9 +56100,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -55877,16 +56114,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -55906,7 +56143,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -55924,7 +56161,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -55934,11 +56171,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -55948,7 +56185,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -55956,18 +56193,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -55981,7 +56218,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -55995,7 +56232,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56005,14 +56242,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56029,7 +56266,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56053,14 +56290,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56101,15 +56338,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56128,7 +56365,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56142,10 +56379,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -56168,7 +56405,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -56177,7 +56414,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -56202,11 +56439,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -56241,10 +56478,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -56259,8 +56496,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -56281,21 +56518,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -56303,13 +56540,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -56330,7 +56567,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -56351,7 +56588,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -56364,7 +56601,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -56373,7 +56610,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -56384,15 +56621,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -56400,56 +56637,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -56472,7 +56709,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -56483,46 +56720,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -56533,7 +56770,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -56546,9 +56783,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -56565,7 +56802,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -56576,10 +56813,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -56592,7 +56829,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -56615,7 +56852,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -56623,7 +56860,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -56632,13 +56869,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -56678,19 +56915,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -56700,7 +56937,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -56711,26 +56948,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -56755,7 +56992,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -56780,7 +57017,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -56788,15 +57025,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -56836,8 +57073,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -56845,8 +57082,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -56860,7 +57097,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -56874,8 +57111,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -56896,7 +57133,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -56915,7 +57152,7 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { @@ -56930,7 +57167,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -56938,19 +57175,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -56965,11 +57202,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -56978,23 +57215,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57006,15 +57243,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57040,22 +57277,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57067,22 +57304,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57108,7 +57345,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57124,14 +57361,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -57168,8 +57405,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -57178,7 +57415,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -57197,9 +57434,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -57224,10 +57461,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -57238,7 +57475,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -57247,7 +57484,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -57296,7 +57533,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -57305,10 +57542,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -57326,9 +57563,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -57354,10 +57591,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -57373,8 +57610,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -57384,7 +57621,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -57401,7 +57638,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -57409,7 +57646,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -57445,8 +57682,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -57481,7 +57718,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -57491,24 +57728,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -57520,7 +57757,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -57533,10 +57770,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -57544,11 +57781,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -57563,7 +57800,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -57726,12 +57963,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -57753,11 +57990,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -57782,8 +58019,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -57791,7 +58028,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -57806,7 +58043,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -57828,7 +58065,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -57838,7 +58075,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -57877,18 +58114,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -57901,7 +58138,8 @@ var ts; if (symbol === globalThisSymbol) { var varsOnly_1 = new ts.Map(); members.forEach(function (p) { - if (!(p.flags & 418 /* BlockScoped */)) { + var _a; + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -57910,10 +58148,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -57929,8 +58167,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -57939,16 +58177,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -57966,20 +58204,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58000,11 +58238,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58014,29 +58252,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58056,7 +58294,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58084,13 +58322,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58103,12 +58341,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58116,7 +58354,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58126,8 +58364,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -58153,7 +58391,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -58161,8 +58399,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -58178,20 +58416,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -58199,34 +58437,34 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -58234,7 +58472,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -58243,7 +58481,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58267,7 +58505,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -58277,13 +58515,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -58302,7 +58540,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -58321,9 +58559,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -58384,7 +58622,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -58402,11 +58640,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -58416,7 +58654,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { hasDisjointDomainType = true; } } @@ -58428,7 +58666,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -58438,11 +58676,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -58467,7 +58705,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -58477,13 +58715,14 @@ var ts; // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of // nesting, so it is effectively just a safety stop. - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + var identity_1 = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) { + stack.push(identity_1); result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -58503,13 +58742,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -58529,23 +58768,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -58556,11 +58795,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -58619,7 +58858,7 @@ var ts; var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -58627,7 +58866,7 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !objectType.declaration.questionToken && !objectType.declaration.nameType); } @@ -58637,17 +58876,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ScriptTarget.ES2020 */) : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ScriptTarget.ES2015 */) : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -58662,21 +58901,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -58689,7 +58928,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -58707,41 +58946,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -58783,18 +59022,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -58807,7 +59046,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -58841,7 +59080,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -58850,15 +59089,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -58868,7 +59107,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -58879,23 +59118,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -58910,7 +59149,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -58930,15 +59169,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -58981,13 +59220,13 @@ var ts; } function isApplicableIndexType(source, target) { // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index - // signature applies to types assignable to 'number' and numeric string literal types. + // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59038,17 +59277,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59063,7 +59302,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59081,7 +59320,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59130,7 +59369,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59142,7 +59381,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -59152,19 +59391,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -59176,25 +59415,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -59216,7 +59455,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -59225,7 +59464,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -59258,7 +59497,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -59270,18 +59509,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -59353,26 +59592,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -59399,7 +59638,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -59409,12 +59648,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -59423,7 +59662,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -59517,8 +59756,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -59532,7 +59771,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -59550,7 +59789,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -59565,8 +59804,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -59577,13 +59816,13 @@ var ts; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -59608,27 +59847,27 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -59653,10 +59892,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -59665,7 +59904,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -59693,7 +59932,7 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type @@ -59707,13 +59946,13 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; @@ -59735,7 +59974,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -59746,13 +59985,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -59787,14 +60026,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -59825,12 +60064,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -59865,9 +60104,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -59879,21 +60118,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -59915,10 +60154,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -59926,14 +60165,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -59949,7 +60188,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -59960,22 +60199,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -59985,27 +60224,41 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); } } + // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the + // template type XXX, K has an added constraint of number | `${number}`. + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { + var mappedType = getTypeFromTypeNode(parent); + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + var typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + var constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = ts.append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60061,7 +60314,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60073,13 +60326,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60120,9 +60373,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60132,7 +60385,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -60143,13 +60396,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -60185,9 +60438,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -60252,7 +60505,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -60290,20 +60543,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -60312,14 +60565,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -60328,18 +60581,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -60348,28 +60601,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -60382,33 +60635,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -60426,7 +60679,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -60436,8 +60689,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -60445,8 +60698,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -60456,7 +60709,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -60474,26 +60727,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -60512,10 +60765,10 @@ var ts; var _loop_15 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -60530,7 +60783,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -60545,12 +60798,12 @@ var ts; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -60560,13 +60813,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -60618,19 +60871,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -60664,18 +60917,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -60689,20 +60942,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -60720,11 +60973,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -60738,7 +60991,7 @@ var ts; var _loop_16 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; @@ -60748,17 +61001,17 @@ var ts; } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -60777,7 +61030,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -60786,37 +61039,37 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; @@ -60840,11 +61093,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -60853,8 +61106,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -60891,20 +61144,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -60915,41 +61168,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -60967,10 +61220,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -60983,10 +61236,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61000,11 +61253,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61021,7 +61274,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61033,7 +61286,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61042,7 +61295,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61071,12 +61324,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61105,37 +61358,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { + if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -61147,21 +61400,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -61173,8 +61426,8 @@ var ts; var constituents = getCrossProductIntersections(typeSet); // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions). - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -61185,12 +61438,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -61203,7 +61456,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -61211,7 +61464,7 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; @@ -61225,13 +61478,13 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -61263,7 +61516,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -61279,8 +61532,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -61300,12 +61553,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -61317,11 +61570,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -61331,14 +61584,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -61356,16 +61609,16 @@ var ts; function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) + return type.flags & 1048576 /* TypeFlags.Union */ ? isPossiblyReducibleByInstantiation(type) ? getIndexTypeForGenericType(type, stringsOnly) : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -61376,21 +61629,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -61407,7 +61660,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -61426,10 +61679,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -61440,13 +61693,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -61459,7 +61712,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -61472,35 +61725,35 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -61508,13 +61761,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -61535,16 +61788,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -61559,26 +61812,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -61588,7 +61841,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -61596,12 +61849,12 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -61613,33 +61866,33 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -61647,21 +61900,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -61683,20 +61936,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -61713,10 +61966,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -61734,62 +61987,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -61814,7 +62067,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -61828,17 +62081,20 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } } - // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where + // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P. + // For example, for an index access { [P in K]: Box }[X], we construct the type Box. + if (isGenericMappedType(objectType)) { + var nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); }); + } } return type[cache] = type; } @@ -61848,19 +62104,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -61870,7 +62126,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -61878,12 +62134,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -61894,33 +62150,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -61932,12 +62188,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -61953,11 +62209,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -61965,8 +62221,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -61976,7 +62232,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -61988,11 +62244,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62057,7 +62313,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62075,7 +62331,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62091,15 +62347,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -62117,7 +62373,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -62128,7 +62384,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -62156,14 +62412,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -62191,7 +62447,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -62214,7 +62470,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -62257,7 +62513,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -62270,7 +62526,7 @@ var ts; var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references @@ -62293,7 +62549,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -62307,7 +62563,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -62323,7 +62579,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -62336,7 +62592,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -62345,13 +62601,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -62371,13 +62627,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62386,7 +62642,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -62396,31 +62652,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -62430,7 +62686,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -62444,7 +62700,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -62459,11 +62715,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -62476,23 +62732,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -62510,7 +62766,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -62521,39 +62777,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -62563,9 +62819,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -62581,20 +62837,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -62616,17 +62872,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -62642,99 +62898,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -62772,9 +63028,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -62783,22 +63039,22 @@ var ts; } } return type; - case 2 /* Function */: + case 2 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 3 /* TypeMapKind.Composite */: + case 4 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 3 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return { kind: 0 /* TypeMapKind.Simple */, source: source, target: target }; } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return { kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }; } function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + return { kind: 2 /* TypeMapKind.Function */, func: func }; } function makeCompositeTypeMapper(kind, mapper1, mapper2) { return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; @@ -62814,16 +63070,16 @@ var ts; return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(3 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -62856,7 +63112,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -62868,7 +63124,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -62877,7 +63133,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -62891,12 +63147,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -62909,8 +63165,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -62931,8 +63187,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -62941,8 +63197,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -62951,7 +63207,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -62960,15 +63216,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -62979,9 +63235,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63003,11 +63259,11 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -63027,7 +63283,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63036,14 +63292,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63053,11 +63309,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63067,13 +63323,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63082,7 +63338,7 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; @@ -63107,7 +63363,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -63127,7 +63383,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -63140,62 +63396,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -63205,11 +63461,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -63219,15 +63475,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -63248,35 +63504,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -63290,17 +63546,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -63309,7 +63565,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -63319,13 +63575,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -63342,11 +63598,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -63384,7 +63640,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -63394,35 +63650,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -63446,7 +63702,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -63464,7 +63720,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -63481,7 +63737,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -63491,7 +63747,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -63508,7 +63764,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -63528,8 +63784,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -63553,7 +63809,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -63619,18 +63875,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -63655,7 +63911,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -63737,7 +63993,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -63747,7 +64003,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -63772,17 +64028,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -63804,7 +64060,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & 131068 /* TypeFlags.Primitive */) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -63816,8 +64072,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -63833,16 +64089,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -63854,10 +64110,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -63869,7 +64125,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -63888,27 +64144,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* TypeFlags.Nullable */) === (getFalsyFlags(targetType) & 98304 /* TypeFlags.Nullable */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -63931,14 +64187,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -63953,21 +64209,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -63993,19 +64249,19 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64014,83 +64270,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; } return false; @@ -64106,38 +64362,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getReducedType(type) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) @@ -64166,19 +64422,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -64216,10 +64472,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -64264,24 +64520,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -64310,7 +64566,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -64323,7 +64579,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -64375,7 +64631,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperType && target !== markerSubType) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -64397,7 +64653,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -64445,7 +64701,7 @@ var ts; } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -64459,7 +64715,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -64468,19 +64724,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -64489,73 +64745,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -64574,10 +64830,10 @@ var ts; // // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. - if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -64587,10 +64843,9 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { - var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -64599,20 +64854,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -64631,25 +64886,22 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -64664,7 +64916,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -64672,19 +64924,19 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } var _loop_19 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { @@ -64739,7 +64991,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -64762,28 +65014,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -64791,16 +65043,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64808,13 +65060,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -64822,7 +65074,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -64831,19 +65083,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64851,50 +65103,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64905,54 +65157,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64966,28 +65218,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); } - if (saved & 16 /* ReportsUnreliable */) { + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65003,42 +65255,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65046,30 +65298,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -65078,14 +65330,14 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; @@ -65095,29 +65347,29 @@ var ts; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -65125,18 +65377,18 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { + if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -65150,10 +65402,10 @@ var ts; // needs to have its constraint hoisted into an intersection with said type parameter, this way // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65165,20 +65417,20 @@ var ts; // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -65187,34 +65439,34 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65227,8 +65479,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -65243,7 +65495,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -65251,18 +65503,18 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65280,14 +65532,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -65306,12 +65558,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -65319,22 +65571,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -65354,7 +65606,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -65364,12 +65616,12 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -65380,8 +65632,8 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { resetErrorInfo(saveErrorInfo); return result; @@ -65389,37 +65641,37 @@ var ts; } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source); - if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) { + if (!constraint || (sourceFlags & 262144 /* TypeFlags.TypeParameter */ && constraint.flags & 1 /* TypeFlags.Any */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* TypeFlags.NonPrimitive */), 3 /* RecursionFlags.Both */)) { resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65428,7 +65680,7 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65436,44 +65688,44 @@ var ts; } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */ && source.symbol === target.symbol) { + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -65482,15 +65734,15 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -65503,7 +65755,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65513,7 +65765,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -65522,7 +65774,7 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -65531,22 +65783,22 @@ var ts; return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -65556,41 +65808,41 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -65607,9 +65859,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -65617,7 +65869,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -65627,7 +65879,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -65654,8 +65906,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -65687,14 +65939,14 @@ var ts; var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -65709,7 +65961,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -65721,8 +65973,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -65731,7 +65983,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -65752,7 +66004,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -65769,7 +66021,7 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { @@ -65779,20 +66031,20 @@ var ts; return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -65819,40 +66071,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -65862,7 +66114,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -65870,10 +66122,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -65884,7 +66136,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -65895,7 +66147,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -65937,29 +66189,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -65970,38 +66222,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66009,12 +66261,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66024,14 +66276,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66040,18 +66292,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -66063,12 +66315,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66077,24 +66329,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66106,17 +66358,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -66125,18 +66377,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -66144,7 +66396,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66159,10 +66411,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -66188,18 +66440,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -66222,45 +66474,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66270,7 +66522,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66278,7 +66530,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -66295,14 +66547,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66313,46 +66565,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -66365,19 +66617,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -66386,7 +66638,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -66406,7 +66658,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -66441,12 +66693,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -66462,7 +66714,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -66478,14 +66730,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; var _loop_22 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -66496,22 +66748,22 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } @@ -66532,7 +66784,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -66543,34 +66795,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -66578,7 +66830,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -66614,12 +66866,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -66634,7 +66886,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } // Return the inherited type of the given property or undefined if property doesn't exist in a base class. function getTypeOfPropertyInBaseClass(property) { @@ -66652,13 +66904,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -66676,12 +66928,12 @@ var ts; function isDeeplyNestedType(type, stack, depth, maxDepth) { if (maxDepth === void 0) { maxDepth = 3; } if (depth >= maxDepth) { - var identity_1 = getRecursionIdentity(type); + var identity_2 = getRecursionIdentity(type); var count = 0; var lastTypeId = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (getRecursionIdentity(t) === identity_1) { + if (getRecursionIdentity(t) === identity_2) { // We only count occurrences with a higher type id than the previous occurrence, since higher // type ids are an indicator of newer instantiations caused by recursion. if (t.id >= lastTypeId) { @@ -66704,14 +66956,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -66721,49 +66973,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -66794,14 +67046,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -66812,12 +67064,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -66825,7 +67077,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66837,7 +67089,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66851,10 +67103,10 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; @@ -66885,20 +67137,23 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : - getUnionType(types, 2 /* Subtype */); + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* TypeFlags.Nullable */) : + getUnionType(types, 2 /* UnionReduction.Subtype */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; + } + function isArrayOrTupleType(type) { + return isArrayType(type) || isTupleType(type); } function isMutableArrayOrTuple(type) { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; @@ -66909,22 +67164,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -66939,7 +67194,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -66966,44 +67221,44 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getBaseTypeOfLiteralType) : type; } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67034,10 +67289,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -67058,7 +67313,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -67066,7 +67321,7 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; @@ -67084,31 +67339,31 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 : - type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 : - type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 : - type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 : - type.flags & 117724 /* PossiblyFalsy */; + return type.flags & 1048576 /* TypeFlags.Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value === "" ? 128 /* TypeFlags.StringLiteral */ : 0 : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? type.value === 0 ? 256 /* TypeFlags.NumberLiteral */ : 0 : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* TypeFlags.BigIntLiteral */ : 0 : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* TypeFlags.BooleanLiteral */ : 0 : + type.flags & 117724 /* TypeFlags.PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* TypeFlags.DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* TypeFlags.DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -67117,24 +67372,24 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' // that isn't eliminated by a NonNullable instantiation. - var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + var reducedType = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? @@ -67162,10 +67417,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -67188,23 +67443,23 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -67234,7 +67489,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -67245,7 +67500,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -67275,7 +67530,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -67287,7 +67542,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -67303,7 +67558,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -67322,36 +67577,36 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -67374,8 +67629,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -67388,7 +67643,7 @@ var ts; } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { @@ -67400,7 +67655,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -67419,17 +67674,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -67440,25 +67695,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -67467,10 +67722,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -67482,7 +67737,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -67585,9 +67840,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -67633,40 +67888,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? false : "quit"; })); } return false; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || - type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -67674,7 +67929,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -67702,7 +67957,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -67719,14 +67974,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -67761,7 +68016,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -67771,9 +68026,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -67791,7 +68046,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -67802,7 +68057,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -67824,12 +68079,12 @@ var ts; sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); } function isValidBigIntString(s) { - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - if (result === 40 /* MinusToken */) { + if (result === 40 /* SyntaxKind.MinusToken */) { result = scanner.scan(); } var flags = scanner.getTokenFlags(); @@ -67838,27 +68093,27 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */); } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || - target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + return !!(target.flags & 8 /* TypeFlags.Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* TypeFlags.BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -67868,7 +68123,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -67950,12 +68205,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -67977,7 +68232,7 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -67986,10 +68241,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68004,21 +68259,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -68026,10 +68281,10 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -68037,12 +68292,12 @@ var ts; // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* InferencePriority.ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -68067,7 +68322,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -68080,11 +68335,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -68092,45 +68347,45 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); contravariant = !contravariant; } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); var oldPriority = priority; - priority |= 4 /* SubstituteSource */; + priority |= 4 /* InferencePriority.SubstituteSource */; inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority priority = oldPriority; } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -68138,17 +68393,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -68161,7 +68416,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -68179,19 +68434,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -68199,7 +68454,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -68227,7 +68482,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -68236,7 +68491,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -68246,7 +68501,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -68260,7 +68515,7 @@ var ts; var typeVariable; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -68270,9 +68525,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -68288,11 +68543,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -68303,7 +68558,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -68337,17 +68592,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -68355,7 +68610,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -68367,17 +68622,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -68396,7 +68651,7 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); @@ -68404,7 +68659,7 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; @@ -68426,7 +68681,7 @@ var ts; } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -68441,7 +68696,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -68449,7 +68704,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); @@ -68464,21 +68719,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -68487,14 +68742,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -68514,8 +68769,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -68535,7 +68790,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -68543,9 +68798,9 @@ var ts; function inferFromSignature(source, target, skipParameters) { if (!skipParameters) { var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -68553,7 +68808,7 @@ var ts; } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -68561,9 +68816,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -68588,34 +68843,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -68632,8 +68887,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -68647,14 +68902,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -68675,7 +68930,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -68745,7 +69000,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -68757,7 +69012,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -68766,7 +69021,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -68774,22 +69029,22 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -68800,44 +69055,44 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -68858,15 +69113,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -68905,12 +69160,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -68940,7 +69195,7 @@ var ts; var map = new ts.Map(); var count = 0; var _loop_23 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -68976,15 +69231,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -69008,7 +69263,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -69025,7 +69280,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -69039,7 +69294,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69055,11 +69310,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { + if (assignedType.flags & 131072 /* TypeFlags.Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { + if (assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType)) { reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types } // Our crude heuristic produces an invalid result in some cases: see GH#26130. @@ -69082,93 +69337,93 @@ var ts; function getTypeFacts(type, ignoreObjects) { if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; - if (flags & 4 /* String */) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & 4 /* TypeFlags.String */) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & 128 /* StringLiteral */) { + if (flags & 128 /* TypeFlags.StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { if (ignoreObjects) { - return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection. + return 16768959 /* TypeFacts.AndFactsMask */; // This is the identity element for computing type facts of intersection. } - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 16318463 /* TypeFacts.EmptyObjectStrictFacts */ : 16777215 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { - return 9830144 /* UndefinedFacts */; + if (flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { + return 9830144 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 9363232 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 9363232 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 465829888 /* Instantiable */) { + if (flags & 465829888 /* TypeFlags.Instantiable */) { return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : - strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; + strictNullChecks ? 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */)); return getIntersectionTypeFacts(type, ignoreObjects); } - return 16777215 /* All */; + return 16777215 /* TypeFacts.All */; } function getIntersectionTypeFacts(type, ignoreObjects) { // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 16777215 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 16777215 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; var f = getTypeFacts(t, ignoreObjects); oredFacts |= f; andedFacts &= f; } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 16768959 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -69188,7 +69443,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -69199,18 +69454,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -69227,21 +69482,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -69249,7 +69504,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -69267,37 +69522,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -69305,13 +69560,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -69331,7 +69586,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -69344,13 +69599,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -69359,25 +69614,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -69385,45 +69640,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -69434,11 +69689,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -69450,13 +69705,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -69468,14 +69723,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -69490,10 +69745,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -69501,17 +69756,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { var t = types_18[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -69525,16 +69780,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -69543,11 +69798,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -69558,11 +69813,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -69577,16 +69832,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -69604,7 +69859,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -69618,10 +69873,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -69629,7 +69884,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -69639,10 +69894,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -69662,8 +69917,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -69671,7 +69926,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -69679,30 +69934,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -69710,7 +69965,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -69718,7 +69973,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -69729,7 +69984,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -69738,7 +69993,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -69746,24 +70001,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -69773,18 +70028,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -69810,8 +70065,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -69827,7 +70082,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -69836,7 +70091,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -69849,56 +70104,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -69922,7 +70177,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -69934,7 +70189,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -69945,7 +70200,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -69962,14 +70217,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -69977,14 +70232,14 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -69994,15 +70249,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : - predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -70011,15 +70266,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -70028,7 +70283,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -70042,7 +70297,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -70052,7 +70307,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -70067,16 +70322,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -70093,7 +70348,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -70137,7 +70392,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -70163,7 +70418,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -70216,7 +70471,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -70231,7 +70486,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -70277,8 +70532,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -70294,8 +70549,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -70303,16 +70558,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -70321,7 +70576,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -70332,52 +70587,52 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType : - getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return type.flags & 2 /* TypeFlags.Unknown */ && assumeTrue ? nonNullUnknownType : + getTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -70409,35 +70664,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -70470,48 +70725,48 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) { + if (assumeTrue && (type.flags & 2 /* TypeFlags.Unknown */) && (operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */) && (valueType.flags & 65536 /* TypeFlags.Null */)) { return getUnionType([nullType, undefinedType]); } - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; - return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; + return type.flags & 2 /* TypeFlags.Unknown */ && facts & (1048576 /* TypeFacts.NENull */ | 2097152 /* TypeFacts.NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -70523,34 +70778,34 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } - if (type.flags & 1 /* Any */ && literal.text === "function") { + if (type.flags & 1 /* TypeFlags.Any */ && literal.text === "function") { return type; } - if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { + if (assumeTrue && type.flags & 2 /* TypeFlags.Unknown */ && literal.text === "object") { // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null // unknown type, and then narrows that to the non-primitive type. return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeFacts.TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */; var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text); return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -70563,16 +70818,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -70585,20 +70840,20 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { switch (text) { case "function": - return type.flags & 1 /* Any */ ? type : globalFunctionType; + return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType; case "object": - return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; default: return typeofTypesByName.get(text); } @@ -70617,7 +70872,7 @@ var ts; if (isTypeSubtypeOf(candidate, type)) { return candidate; } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(candidate, constraint)) { return getIntersectionType([type, candidate]); @@ -70692,7 +70947,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -70722,8 +70977,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -70734,7 +70989,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -70757,13 +71012,13 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; @@ -70776,9 +71031,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { + if (!(assignableType.flags & 131072 /* TypeFlags.Never */)) { return assignableType; } } @@ -70796,7 +71051,7 @@ var ts; if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -70806,7 +71061,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -70821,8 +71076,8 @@ var ts; return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { @@ -70837,11 +71092,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -70857,20 +71112,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -70879,11 +71134,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -70894,7 +71149,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -70918,9 +71173,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -70930,8 +71185,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -70940,11 +71195,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -70957,18 +71212,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 32768 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -70980,17 +71235,17 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -70999,8 +71254,8 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) : getContextualType(node)); return contextualType && !isGenericType(contextualType); } @@ -71012,10 +71267,10 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); - return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (n) { @@ -71033,9 +71288,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -71078,16 +71333,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { - var links = getNodeLinks(location); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { + var links = getNodeLinks(parent); + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -71121,7 +71376,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -71152,15 +71407,15 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } // We should only mark aliases as referenced if there isn't a local value declaration @@ -71174,32 +71429,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -71211,19 +71466,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -71232,11 +71487,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -71253,17 +71508,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -71271,11 +71526,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -71292,7 +71547,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -71309,11 +71564,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -71328,12 +71583,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -71343,22 +71598,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -71368,7 +71623,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -71376,9 +71631,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -71388,13 +71643,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -71436,36 +71691,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -71500,7 +71755,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -71548,9 +71803,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -71558,31 +71813,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -71594,17 +71849,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -71614,18 +71869,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -71636,14 +71891,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -71651,26 +71906,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -71732,12 +71987,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -71746,8 +72001,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -71767,12 +72022,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -71782,7 +72037,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -71790,23 +72045,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -71814,22 +72069,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -71856,7 +72111,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -71870,7 +72125,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -71898,7 +72153,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -71923,11 +72178,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -71938,10 +72193,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -71974,7 +72229,7 @@ var ts; if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } @@ -71986,8 +72241,8 @@ var ts; var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var use = functionFlags & 2 /* FunctionFlags.Async */ ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); if (!iterationTypes) { return undefined; @@ -71995,7 +72250,7 @@ var ts; contextualReturnType = iterationTypes.returnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72021,7 +72276,7 @@ var ts; if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); } } return undefined; @@ -72040,7 +72295,7 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); var contextualReturnType = getContextualReturnType(functionDecl); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) @@ -72087,11 +72342,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -72100,13 +72355,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -72115,8 +72370,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -72149,8 +72404,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -72160,11 +72415,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (decl.initializer && getTypeOfExpression(binaryExpression.left)); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -72185,7 +72440,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -72199,18 +72454,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -72218,14 +72473,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -72249,7 +72504,7 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { @@ -72262,7 +72517,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -72283,7 +72538,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72318,7 +72573,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -72373,29 +72628,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -72404,24 +72659,24 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. - if (contextFlags && contextFlags & 1 /* Signature */) { + if (contextFlags && contextFlags & 1 /* ContextFlags.Signature */) { return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); } // For other purposes (e.g. determining whether to produce literal types) we only @@ -72430,7 +72685,7 @@ var ts; // literals actually end up widening to 'boolean' (see #48363). if (inferenceContext.returnMapper) { var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -72442,13 +72697,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -72471,7 +72726,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -72480,60 +72735,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -72546,7 +72801,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -72555,7 +72810,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -72600,7 +72855,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -72615,7 +72870,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -72716,12 +72971,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -72743,18 +72998,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -72784,16 +73039,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -72822,18 +73077,18 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -72846,14 +73101,14 @@ var ts; var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -72869,27 +73124,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -72903,28 +73158,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -72933,14 +73188,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -72951,17 +73206,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -72977,7 +73232,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -72989,11 +73244,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -73013,9 +73268,9 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -73037,16 +73292,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -73058,29 +73313,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -73095,17 +73350,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -73139,10 +73394,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -73167,11 +73422,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -73203,12 +73458,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -73218,8 +73473,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -73265,7 +73520,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -73289,15 +73544,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -73312,7 +73567,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -73328,6 +73583,7 @@ var ts; } } else { + error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -73338,7 +73594,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -73352,7 +73608,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -73380,7 +73636,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -73390,12 +73646,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -73407,7 +73663,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -73427,7 +73683,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -73446,13 +73702,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -73501,10 +73757,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -73517,7 +73773,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -73532,7 +73788,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -73556,7 +73812,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -73570,10 +73826,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -73586,12 +73842,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -73619,13 +73875,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -73656,10 +73912,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -73693,7 +73949,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -73711,20 +73967,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -73733,7 +73989,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -73758,7 +74014,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -73770,7 +74026,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -73781,10 +74037,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -73807,13 +74063,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -73827,9 +74083,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -73852,7 +74108,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -73860,7 +74116,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -73872,7 +74128,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -73883,12 +74139,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -73915,7 +74171,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -73923,10 +74179,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -73941,10 +74197,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -73954,39 +74210,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */; if (kind) { reportError(node, kind); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -73995,13 +74251,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -74014,7 +74270,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -74038,7 +74294,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -74110,16 +74366,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -74141,8 +74397,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -74158,15 +74414,20 @@ var ts; prop = getPropertyOfType(apparentType, right.escapedText); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined + // here even if `Foo` is not a const enum. + // // The exceptions are: // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. - if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -74174,7 +74435,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -74194,7 +74455,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -74206,7 +74467,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -74225,11 +74486,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -74239,12 +74500,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -74257,12 +74518,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -74275,7 +74536,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) { error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; @@ -74293,13 +74554,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -74310,25 +74571,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -74340,7 +74601,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -74365,7 +74626,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -74453,7 +74714,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -74464,7 +74725,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -74472,7 +74733,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -74491,7 +74752,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -74507,7 +74768,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -74538,7 +74799,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -74566,7 +74827,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -74576,16 +74837,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -74595,19 +74856,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -74622,7 +74883,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -74662,13 +74923,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -74685,13 +74946,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -74705,7 +74966,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -74714,7 +74975,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -74726,8 +74987,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -74740,13 +75001,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -74810,16 +75071,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -74827,9 +75088,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -74840,11 +75101,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -74858,7 +75119,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -74882,7 +75143,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -74898,20 +75159,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -74920,12 +75181,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -74933,7 +75194,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -74961,8 +75222,8 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { - var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); + if (node.kind !== 165 /* SyntaxKind.Decorator */) { + var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { @@ -74970,7 +75231,7 @@ var ts; // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. var outerContext = getInferenceContext(node); - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -74984,7 +75245,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of // the source type uses the outer context's return mapper (which excludes inferences made from @@ -74998,7 +75259,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -75011,7 +75272,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -75026,10 +75287,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -75037,7 +75298,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -75047,24 +75308,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -75094,16 +75355,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -75128,7 +75389,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -75136,12 +75397,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -75151,7 +75412,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -75208,7 +75469,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -75226,13 +75487,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -75271,8 +75532,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -75290,17 +75551,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -75314,12 +75575,12 @@ var ts; var _loop_24 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -75341,30 +75602,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -75378,17 +75639,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -75422,7 +75683,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -75464,8 +75725,14 @@ var ts; var parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && ts.isInJSFile(node)) { + return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + var error = hasRestParameter + ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : ts.Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { // between min and max, but with no matching overload @@ -75524,15 +75791,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -75559,7 +75826,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -75587,7 +75855,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -75620,7 +75888,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -75643,7 +75911,7 @@ var ts; var i_1 = 0; var _loop_25 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -75728,7 +75996,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -75751,9 +76019,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -75775,7 +76043,7 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = 0 /* Normal */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -75828,14 +76096,14 @@ var ts; _loop_26(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -75848,7 +76116,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -75885,8 +76153,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -75906,7 +76174,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -75921,7 +76189,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -75930,13 +76198,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -75951,8 +76219,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -75979,7 +76247,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -75995,7 +76263,7 @@ var ts; // use the resolvingSignature singleton to indicate that we deferred processing. This result will be // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -76016,11 +76284,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -76053,7 +76321,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -76062,24 +76330,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -76090,14 +76358,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -76105,7 +76373,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -76113,7 +76381,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -76136,9 +76404,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -76146,16 +76414,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -76164,10 +76432,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { @@ -76217,7 +76485,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -76261,8 +76529,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76272,26 +76540,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -76306,8 +76574,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -76318,38 +76586,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -76370,7 +76638,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -76386,16 +76654,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -76418,7 +76686,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -76459,7 +76727,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -76495,16 +76763,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -76527,10 +76795,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -76550,15 +76818,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -76575,11 +76843,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -76592,14 +76860,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -76608,20 +76876,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -76643,7 +76911,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -76658,13 +76926,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -76680,11 +76948,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + newSymbol.aliasTarget = resolveSymbol(symbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -76707,7 +76975,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -76727,40 +76995,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -76768,31 +77036,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -76823,12 +77091,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -76853,7 +77121,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -76861,12 +77129,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -76875,10 +77143,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -76894,19 +77162,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -76919,7 +77187,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -76929,16 +77197,16 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -76971,7 +77239,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77003,7 +77271,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -77053,11 +77321,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -77081,14 +77349,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -77096,7 +77364,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -77106,7 +77374,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -77136,7 +77404,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -77156,7 +77424,7 @@ var ts; } } var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { // The contextual signature has a generic rest parameter. We first instantiate the contextual // signature (without fixing type parameters) and assign types to contextually typed parameters. var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); @@ -77200,7 +77468,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -77220,7 +77488,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -77239,7 +77507,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -77287,8 +77555,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -77300,14 +77568,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -77322,36 +77590,36 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { @@ -77360,9 +77628,9 @@ var ts; contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -77376,7 +77644,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -77419,13 +77687,13 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { @@ -77439,7 +77707,7 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -77451,14 +77719,14 @@ var ts; * whether the active clause contains a default clause. */ function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; // When in the default we only collect inequality facts // because default is 'in theory' a set of infinite // equalities. if (hasDefault) { // Value is not equal to any types after the active clause. for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -77468,7 +77736,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -77476,7 +77744,7 @@ var ts; else { // Add equalities for all types in the active clause. for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeFacts.TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -77491,17 +77759,17 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); var type_6 = getBaseConstraintOfType(operandType) || operandType; // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types. - if (type_6.flags & 3 /* AnyOrUnknown */) { - return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */; + if (type_6.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_1) === 556800 /* TypeFacts.AllTypeofNE */; } - return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* TypeFlags.Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -77525,15 +77793,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -77554,11 +77822,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -77579,17 +77847,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -77618,13 +77886,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -77635,9 +77903,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -77645,7 +77913,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -77654,21 +77922,21 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); } var instantiatedContextualSignature = inferenceContext ? @@ -77691,7 +77959,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -77704,7 +77972,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -77716,7 +77984,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -77774,27 +78042,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -77815,11 +78083,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -77827,12 +78095,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -77861,8 +78129,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -77880,21 +78148,36 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = void 0; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -77904,7 +78187,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -77920,7 +78203,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -77931,16 +78214,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -77948,28 +78231,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -77992,8 +78275,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -78013,7 +78296,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var t = types_21[_i]; @@ -78028,30 +78311,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -78063,7 +78346,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -78077,8 +78360,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -78091,8 +78374,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -78117,9 +78400,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -78139,7 +78422,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -78150,17 +78433,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -78182,18 +78465,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -78202,15 +78485,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -78221,7 +78504,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -78237,14 +78520,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* TypeFlags.Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -78253,31 +78536,31 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -78292,59 +78575,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -78375,9 +78658,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -78394,8 +78677,8 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var parent = ts.walkUpParenthesizedExpressions(node.parent); checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } @@ -78455,11 +78738,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -78468,11 +78751,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -78484,28 +78767,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -78514,8 +78797,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -78526,21 +78809,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -78556,26 +78839,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -78593,21 +78876,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -78616,56 +78899,56 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -78675,7 +78958,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -78693,16 +78976,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -78712,12 +78995,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -78727,15 +79010,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -78754,7 +79037,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -78768,13 +79051,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -78817,12 +79100,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -78848,20 +79131,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -78878,15 +79161,15 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { @@ -78900,7 +79183,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -78913,7 +79196,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -78926,7 +79209,7 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); @@ -78935,11 +79218,11 @@ var ts; return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -78951,7 +79234,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -78960,7 +79243,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -78973,7 +79256,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -78993,17 +79276,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -79013,9 +79296,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -79024,7 +79307,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -79039,28 +79322,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -79081,7 +79364,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -79092,23 +79375,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -79156,11 +79439,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -79190,7 +79473,7 @@ var ts; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -79215,7 +79498,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -79248,7 +79531,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -79260,7 +79543,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -79275,7 +79558,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -79285,8 +79568,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -79306,7 +79589,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -79317,7 +79600,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -79335,18 +79618,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -79364,113 +79647,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -79495,19 +79778,28 @@ var ts; if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) { + checkNodeDeferred(node); + addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); + } + function checkTypeParameterDeferred(node) { + if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) { + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); var modifiers = getVarianceModifiers(typeParameter); - if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { + if (modifiers) { var symbol = getSymbolOfNode(node.parent); - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); - var saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { + error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubType : markerSuperType); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperType : markerSubType); + var saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); }); } function checkParameter(node) { // Grammar checking @@ -79517,11 +79809,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -79532,13 +79824,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -79562,7 +79854,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -79596,13 +79888,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -79616,11 +79908,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -79629,29 +79921,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -79667,17 +79959,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -79689,18 +79981,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -79712,11 +80004,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -79727,24 +80019,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -79754,19 +80046,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -79815,15 +80107,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -79840,7 +80132,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -79888,7 +80180,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -79905,7 +80197,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -79915,9 +80207,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -79925,8 +80217,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -79958,7 +80250,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -79979,9 +80271,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -79997,7 +80289,7 @@ var ts; superCallStatement = statement; break; } - if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -80020,7 +80312,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -80038,9 +80330,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -80048,25 +80340,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -80078,7 +80370,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -80110,15 +80402,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -80134,10 +80426,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -80176,29 +80468,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -80218,15 +80510,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -80234,14 +80526,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -80290,7 +80582,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -80300,7 +80592,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -80327,8 +80619,8 @@ var ts; if (node.assertions) { var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -80338,31 +80630,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -80387,16 +80679,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -80413,8 +80705,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -80423,7 +80715,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -80452,7 +80744,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -80477,7 +80769,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -80493,8 +80785,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -80505,10 +80797,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -80552,13 +80844,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -80568,7 +80860,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -80608,15 +80900,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -80649,56 +80941,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -80734,32 +81026,32 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -80779,16 +81071,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -80798,7 +81090,7 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } @@ -80822,7 +81114,7 @@ var ts; var baseConstraint = getBaseConstraintOfType(type); // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { + if (!baseConstraint || (baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { // Nothing to do if `Awaited` doesn't exist var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); if (awaitedSymbol) { @@ -80868,7 +81160,7 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); } @@ -80985,7 +81277,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -81008,10 +81300,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -81031,7 +81323,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -81044,26 +81336,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -81085,9 +81377,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -81122,15 +81414,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -81139,13 +81431,13 @@ var ts; var commonEntityName; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -81190,15 +81482,15 @@ var ts; error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } var firstDecorator = node.decorators[0]; - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -81207,23 +81499,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -81313,9 +81605,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -81329,7 +81621,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -81345,7 +81637,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -81355,7 +81647,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -81373,7 +81665,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -81401,42 +81693,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -81447,41 +81739,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -81492,7 +81784,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -81509,7 +81801,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -81521,17 +81813,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -81568,7 +81860,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -81599,7 +81891,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -81615,10 +81907,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -81631,9 +81923,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -81652,38 +81944,38 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -81700,7 +81992,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -81718,17 +82010,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -81748,8 +82040,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -81763,8 +82055,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -81778,53 +82070,53 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -81835,7 +82127,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -81843,13 +82135,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -81867,7 +82159,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -81899,35 +82191,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -81958,23 +82250,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } if (ts.isBindingElement(node)) { - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -81984,15 +82276,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -82003,7 +82295,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -82020,7 +82312,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -82031,7 +82323,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -82045,7 +82337,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -82061,7 +82353,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (node.initializer) { @@ -82071,10 +82363,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -82082,7 +82374,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -82092,24 +82384,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -82135,7 +82427,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -82144,13 +82436,13 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) @@ -82164,7 +82456,7 @@ var ts; // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -82204,7 +82496,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -82228,7 +82520,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -82258,7 +82550,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -82269,12 +82561,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -82299,29 +82591,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -82353,7 +82645,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -82367,7 +82659,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -82380,7 +82672,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -82397,7 +82689,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -82412,14 +82704,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -82428,10 +82720,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -82448,22 +82740,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -82471,7 +82763,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -82483,7 +82775,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -82492,12 +82784,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -82505,9 +82797,9 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { - return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; @@ -82554,9 +82846,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -82626,17 +82918,17 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } return undefined; } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; @@ -82646,7 +82938,7 @@ var ts; var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; @@ -82685,20 +82977,20 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? + return use & 8 /* IterationUse.ForOfFlag */ ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { // for a sync iterable in an async context, only use the cached types if they are valid. if (iterationTypes !== noIterationTypes) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); @@ -82709,16 +83001,16 @@ var ts; } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : noIterationTypes); @@ -82784,7 +83076,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -82799,11 +83091,11 @@ var ts; function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } @@ -82883,13 +83175,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -82944,15 +83236,15 @@ var ts; if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" @@ -83058,7 +83350,7 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); @@ -83070,15 +83362,15 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync) || errorType : isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -83098,21 +83390,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -83123,7 +83415,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -83131,7 +83423,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -83152,7 +83444,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -83161,7 +83453,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -83198,7 +83490,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -83230,8 +83522,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -83243,7 +83535,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -83263,8 +83555,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -83293,9 +83585,9 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; var _loop_28 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared @@ -83315,7 +83607,7 @@ var ts; function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; var _loop_29 = function (info) { if (info === checkInfo) @@ -83356,7 +83648,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -83435,9 +83727,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -83524,7 +83816,7 @@ var ts; if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -83545,15 +83837,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -83585,18 +83877,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -83631,7 +83923,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -83681,7 +83973,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -83695,7 +83987,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -83714,12 +84006,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -83732,13 +84024,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -83749,9 +84041,9 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible @@ -83783,10 +84075,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -83802,7 +84094,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -83814,7 +84106,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -83822,11 +84114,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -83849,7 +84141,7 @@ var ts; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -83868,7 +84160,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -83882,7 +84174,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -83893,24 +84185,24 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { // either base or derived property is private - not override, skip it continue; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* InterfaceDeclaration */ + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment continue; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -83918,12 +84210,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -83940,16 +84232,16 @@ var ts; continue; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { // method is overridden with method or property -- correct case continue; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -84015,20 +84307,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -84038,7 +84330,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -84053,7 +84345,7 @@ var ts; ts.setParent(reference, staticBlock); reference.flowNode = staticBlock.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) { + if (!(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */)) { return true; } } @@ -84068,7 +84360,7 @@ var ts; ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 32768 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -84081,7 +84373,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -84114,7 +84406,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -84126,8 +84418,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -84152,7 +84444,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -84169,7 +84461,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -84177,20 +84469,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -84200,60 +84492,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -84289,9 +84581,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -84325,7 +84617,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -84354,9 +84646,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -84387,7 +84679,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -84400,7 +84692,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -84410,7 +84702,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -84426,10 +84718,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -84439,7 +84731,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -84471,23 +84763,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -84498,12 +84790,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -84513,7 +84805,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -84524,20 +84816,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -84551,9 +84843,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -84594,39 +84886,39 @@ var ts; // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -84651,15 +84943,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -84685,11 +84977,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -84698,8 +84990,11 @@ var ts; var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration); var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!ts.isNightly()) { + grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -84732,11 +85027,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -84758,20 +85053,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -84780,7 +85075,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -84795,8 +85090,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -84804,10 +85099,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -84827,12 +85122,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -84842,7 +85137,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -84852,7 +85147,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -84900,15 +85195,15 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -84918,7 +85213,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -84930,8 +85225,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -84948,14 +85243,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -84971,10 +85266,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -85009,11 +85304,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -85059,177 +85354,177 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -85310,7 +85605,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -85322,38 +85617,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 163 /* SyntaxKind.TypeParameter */: + checkTypeParameterDeferred(node); + break; + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -85361,7 +85659,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -85373,9 +85671,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -85387,7 +85685,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -85407,13 +85705,13 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -85437,7 +85735,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -85507,14 +85805,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -85522,17 +85820,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -85540,17 +85838,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -85594,7 +85892,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -85602,25 +85900,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -85628,16 +85926,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -85665,13 +85963,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -85682,12 +85980,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -85697,7 +85995,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -85707,7 +86005,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -85717,17 +86015,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -85743,28 +86041,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -85775,13 +86073,13 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name)); if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { @@ -85793,16 +86091,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -85814,12 +86112,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -85834,7 +86132,7 @@ var ts; function resolveJSDocMemberName(name, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -85846,18 +86144,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -85871,12 +86169,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -85884,27 +86182,32 @@ var ts; return propertyDeclaration; } } - else if (ts.isMetaProperty(parent)) { - var parentType = getTypeOfNode(parent); - var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === 103 /* NewKeyword */) { + else if (ts.isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { + // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } + // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but + // we have a fake expression type made for other reasons already, whose transient `meta` + // member should more exactly be the kind of (declarationless) symbol we want. + // (See #44364 and #45031 for relevant implementation PRs) + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { + return getGlobalImportMetaExpressionType().members.get("meta"); + } + // no other meta properties are valid syntax, thus no others should have symbols + return undefined; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -85916,25 +86219,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -85943,7 +86246,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -85951,19 +86254,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -85973,14 +86276,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -85989,17 +86292,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -86030,7 +86333,7 @@ var ts; if (ts.isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { var symbol = getSymbolAtLocation(node); @@ -86040,7 +86343,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -86061,23 +86364,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -86087,7 +86390,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -86120,14 +86423,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -86137,8 +86440,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -86157,18 +86460,18 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] - : ts.singleElementArray(tryGetAliasTarget(symbol)); + : ts.singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol) { + function tryGetTarget(symbol) { var target; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -86207,13 +86510,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -86231,19 +86534,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -86266,7 +86569,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -86275,20 +86578,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -86304,9 +86607,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -86347,20 +86650,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -86368,7 +86671,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -86385,7 +86688,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -86398,9 +86701,9 @@ var ts; if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } - var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -86438,18 +86741,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); - } - function isOptionalUninitializedParameter(parameter) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86457,10 +86755,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -86483,19 +86781,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -86505,7 +86803,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -86521,14 +86819,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -86547,28 +86845,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -86584,37 +86882,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -86633,7 +86931,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -86654,7 +86952,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -86762,18 +87060,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -86789,7 +87087,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -86826,7 +87124,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -86837,9 +87135,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -86886,7 +87184,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -86914,12 +87212,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -86990,7 +87288,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -87052,28 +87350,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -87087,29 +87385,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -87128,14 +87426,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -87149,69 +87447,69 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -87223,186 +87521,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ && - node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -87420,41 +87717,41 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.fail(); } @@ -87465,10 +87762,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -87497,7 +87794,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -87522,7 +87819,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -87557,7 +87854,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -87593,7 +87890,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -87622,7 +87919,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -87639,6 +87936,9 @@ var ts; return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { + if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } function checkGrammarClassDeclarationHeritageClauses(node) { @@ -87647,7 +87947,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -87660,7 +87960,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -87676,14 +87976,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -87694,21 +87994,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -87726,7 +88026,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -87737,23 +88037,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */) { + if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -87768,25 +88068,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -87801,14 +88101,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -87828,7 +88128,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -87838,7 +88138,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -87873,16 +88173,32 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ts.ModuleKind.Node16: + case ts.ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level)); + break; + } + // fallthrough + case ts.ModuleKind.ES2022: + case ts.ModuleKind.ESNext: + case ts.ModuleKind.System: + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { + break; + } + // fallthrough + default: + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + break; } } } @@ -87891,8 +88207,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -87903,12 +88219,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -87923,20 +88239,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -87946,22 +88262,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -87969,11 +88285,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -87995,17 +88311,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -88015,26 +88331,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -88042,9 +88358,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -88057,10 +88373,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -88078,7 +88394,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -88086,17 +88402,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -88107,11 +88423,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -88119,8 +88435,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -88135,13 +88451,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -88165,18 +88481,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -88184,7 +88500,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -88201,8 +88517,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -88214,7 +88530,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88223,7 +88539,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -88236,7 +88552,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -88253,8 +88569,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -88281,15 +88597,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -88307,12 +88623,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -88370,7 +88686,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -88380,11 +88696,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -88400,11 +88716,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -88426,14 +88742,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -88441,7 +88757,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -88450,10 +88766,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -88464,7 +88780,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -88481,19 +88797,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -88506,7 +88822,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -88527,7 +88843,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -88561,7 +88877,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -88569,7 +88885,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -88577,10 +88893,10 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } var nodeArguments = node.arguments; if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) { @@ -88588,7 +88904,7 @@ var ts; checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { var assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } if (nodeArguments.length === 0 || nodeArguments.length > 2) { @@ -88604,14 +88920,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -88620,35 +88936,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -88660,9 +88976,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -88670,7 +88986,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -88692,14 +89008,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -88719,17 +89035,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -88843,7 +89159,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -88851,11 +89167,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -88902,8 +89218,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -88949,446 +89265,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -89613,7 +89929,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -89623,7 +89939,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -89766,14 +90082,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -89850,8 +90166,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -89901,19 +90217,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -89981,7 +90297,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -90074,12 +90390,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -90130,7 +90446,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -90143,13 +90459,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -90180,23 +90496,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90214,9 +90530,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -90297,7 +90613,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -90312,27 +90628,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -90394,7 +90710,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -90679,9 +90995,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -90722,14 +91038,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -90744,10 +91060,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -90950,7 +91266,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -91006,8 +91322,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -91033,14 +91349,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -91091,17 +91407,17 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -91112,7 +91428,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -91135,7 +91451,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -91155,10 +91471,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -91171,7 +91487,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -91179,13 +91495,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -91205,15 +91521,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -91233,30 +91549,30 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -91267,80 +91583,80 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. // falls through - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.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 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91350,7 +91666,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -91360,35 +91676,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -91398,40 +91714,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -91445,28 +91761,28 @@ var ts; return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -91475,16 +91791,16 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return ts.visitEachChild(node, visitor, context); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); - var classStatement = facts & 2 /* HasConstructorDecorators */ + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var classStatement = facts & 2 /* ClassFacts.HasConstructorDecorators */ ? createClassDeclarationHeadWithDecorators(node, name) : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; @@ -91492,7 +91808,7 @@ var ts; addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -91504,20 +91820,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -91533,21 +91849,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -91563,7 +91879,7 @@ var ts; // ${members} // } // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : undefined; var classDeclaration = factory.createClassDeclaration( @@ -91572,8 +91888,8 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); @@ -91674,7 +91990,7 @@ var ts; var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -91692,7 +92008,7 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); @@ -91825,12 +92141,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -91981,9 +92297,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -91993,7 +92309,7 @@ var ts; : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); ts.setTextRange(helper, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); return helper; } /** @@ -92021,12 +92337,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); return expression; } @@ -92052,7 +92368,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -92089,13 +92405,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true))); @@ -92111,10 +92427,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -92124,7 +92440,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -92135,12 +92451,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -92157,15 +92473,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -92202,7 +92518,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -92247,83 +92563,83 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return factory.createVoidZero(); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return serializeTypeNode(node.type); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return factory.createIdentifier("Array"); - case 177 /* TypePredicate */: - case 133 /* BooleanKeyword */: + case 177 /* SyntaxKind.TypePredicate */: + case 133 /* SyntaxKind.BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: switch (node.literal.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: - case 8 /* NumericLiteral */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 8 /* SyntaxKind.NumericLiteral */: return factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 151 /* SymbolKeyword */: - return languageVersion < 2 /* ES2015 */ + case 151 /* SyntaxKind.SymbolKeyword */: + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return serializeTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -92336,13 +92652,13 @@ var ts; var serializedUnion; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -92402,7 +92718,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES2015 */ + return languageVersion < 2 /* ScriptTarget.ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -92424,12 +92740,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -92445,14 +92761,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -92480,7 +92796,7 @@ var ts; * available. */ function getGlobalBigIntNameWithFallback() { - return languageVersion < 99 /* ESNext */ + return languageVersion < 99 /* ScriptTarget.ESNext */ ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), /*questionToken*/ undefined, factory.createIdentifier("BigInt"), /*colonToken*/ undefined, factory.createIdentifier("Object")) @@ -92543,7 +92859,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -92571,7 +92887,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { return undefined; } var updated = factory.updatePropertyDeclaration(node, @@ -92602,11 +92918,11 @@ var ts; } var statements = []; resumeLexicalEnvironment(); - var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); + var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement)); + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount)); } // Transform parameters into property assignments. Transforms this: // @@ -92625,12 +92941,12 @@ var ts; if (superStatementIndex >= 0) { ts.addRange(statements, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor + // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = ts.addRange(parameterPropertyAssignments, statements); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - // Add remaining statements from the body, skipping the super() call if it was found - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1)); + // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -92650,10 +92966,10 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node) { @@ -92680,7 +92996,7 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { @@ -92756,7 +93072,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -92776,7 +93092,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -92794,7 +93110,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -92871,7 +93187,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -92879,7 +93195,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -92887,7 +93203,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -92953,7 +93269,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93041,12 +93357,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93071,7 +93387,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93081,7 +93397,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93102,7 +93418,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93110,7 +93426,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93118,7 +93434,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93171,7 +93487,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93218,13 +93534,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93247,8 +93563,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*decorators*/ undefined, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) @@ -93272,14 +93588,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93320,8 +93636,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93381,7 +93697,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -93394,7 +93710,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -93415,7 +93731,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -93423,7 +93739,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -93432,7 +93748,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -93441,7 +93757,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Creates a statement for the provided expression. This is used in calls to `map`. @@ -93486,7 +93802,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -93503,37 +93819,37 @@ var ts; : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* TypeScriptSubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -93548,11 +93864,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -93566,7 +93882,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -93575,7 +93891,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -93592,11 +93908,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -93607,8 +93923,8 @@ var ts; || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -93634,9 +93950,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -93662,7 +93978,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -93725,13 +94041,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -93757,7 +94073,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -93765,50 +94081,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 8388608 /* ContainsClassFields */) { + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 8388608 /* ContainsClassFields */ || - node.transformFlags & 33554432 /* ContainsLexicalSuper */ && + if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -93827,17 +94143,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -93867,7 +94183,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -93883,19 +94199,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -93944,10 +94260,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94009,11 +94325,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94032,7 +94348,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94051,7 +94367,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94065,7 +94381,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var info = void 0; if (info = accessPrivateIdentifier(node.operand.name)) { @@ -94074,7 +94390,7 @@ var ts; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94097,7 +94413,7 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { var operand = visitInvalidSuperProperty(node.operand); return ts.isPrefixUnaryExpression(node) ? factory.updatePrefixUnaryExpression(node, operand) : @@ -94213,7 +94529,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94240,7 +94556,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94282,7 +94598,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94297,12 +94613,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94342,28 +94658,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94371,8 +94687,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94385,19 +94701,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -94426,7 +94742,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94436,19 +94752,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -94477,12 +94793,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -94537,13 +94853,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -94576,7 +94892,7 @@ var ts; } resumeLexicalEnvironment(); var needsSyntheticConstructor = !constructor && isDerivedClass; - var indexOfFirstStatementAfterSuper = 0; + var indexOfFirstStatementAfterSuperAndPrologue = 0; var prologueStatementCount = 0; var superStatementIndex = -1; var statements = []; @@ -94585,8 +94901,11 @@ var ts; superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true); + } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; } } if (needsSyntheticConstructor) { @@ -94622,22 +94941,20 @@ var ts; } } if (parameterPropertyDeclarationCount > 0) { - var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); // If there was a super() call found, add parameter properties immediately after it if (superStatementIndex >= 0) { ts.addRange(statements, parameterProperties); } - // If a synthetic super() call was added, add them just after it - else if (needsSyntheticConstructor) { - statements = __spreadArray(__spreadArray([ - statements[0] - ], parameterProperties, true), statements.slice(1), true); - } - // Since there wasn't a super() call, add them to the top of the constructor else { - statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true); + // Add add parameter properties to the top of the constructor after the prologue + var superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) + superAndPrologueStatementCount++; + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true); } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -94647,7 +94964,7 @@ var ts; addPropertyOrClassStaticBlockStatements(statements, properties, receiver); // Add existing statements after the initial prologues and super call if (constructor) { - ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), @@ -94732,7 +95049,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -94751,7 +95068,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -94771,7 +95088,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -94790,32 +95107,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -94854,13 +95171,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -94870,10 +95187,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -94883,7 +95200,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -94904,24 +95221,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -94934,8 +95251,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -94968,7 +95285,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -94988,7 +95305,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95021,7 +95338,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95031,7 +95348,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95040,12 +95357,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95056,12 +95373,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95077,7 +95394,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95089,7 +95406,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95100,12 +95417,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95116,12 +95433,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95138,9 +95455,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95182,9 +95499,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95198,7 +95515,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95238,7 +95555,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95357,8 +95674,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -95370,10 +95687,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -95389,39 +95706,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -95429,27 +95746,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -95532,7 +95849,7 @@ var ts; /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95548,7 +95865,7 @@ var ts; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95563,7 +95880,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95578,7 +95895,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -95599,7 +95916,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -95653,9 +95970,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -95681,7 +95998,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -95694,10 +96011,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -95741,21 +96058,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -95768,8 +96085,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -95796,30 +96113,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -95839,19 +96156,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -95861,7 +96178,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -95871,7 +96188,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -95886,20 +96203,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -95969,7 +96286,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -96001,7 +96318,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -96023,88 +96340,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -96118,15 +96435,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -96138,7 +96455,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -96147,7 +96464,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -96158,7 +96475,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -96181,7 +96498,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -96208,9 +96525,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -96231,10 +96548,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -96262,10 +96579,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -96277,7 +96594,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -96303,8 +96620,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -96321,8 +96638,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -96350,7 +96667,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -96370,10 +96687,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -96392,18 +96709,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -96411,15 +96728,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -96435,7 +96752,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -96453,7 +96770,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -96499,13 +96816,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateMethodDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96518,13 +96835,13 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); var updated = factory.updateFunctionDeclaration(node, - /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96548,13 +96865,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -96571,13 +96888,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -96588,10 +96905,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -96630,11 +96947,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96643,7 +96960,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96659,32 +96976,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -96692,21 +97009,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -96719,8 +97036,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -96747,30 +97064,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -96790,14 +97107,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -96822,11 +97139,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -96854,29 +97171,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -96918,7 +97235,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -96941,10 +97258,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -96953,7 +97270,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -96963,8 +97280,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -96974,17 +97291,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -97001,7 +97318,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -97035,11 +97352,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -97089,7 +97406,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -97113,12 +97430,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -97144,7 +97461,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -97166,7 +97483,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -97183,7 +97500,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -97199,7 +97516,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -97208,13 +97525,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97222,15 +97539,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -97299,7 +97616,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -97364,7 +97681,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -97404,14 +97721,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - else if (node.kind === 10 /* StringLiteral */) { + else if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 288 /* JsxExpression */) { + else if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -97505,7 +97822,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -97808,11 +98125,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97820,9 +98137,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98012,7 +98329,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -98022,7 +98339,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -98033,15 +98350,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -98056,11 +98373,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -98072,9 +98389,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -98082,115 +98399,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -98201,14 +98518,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -98216,17 +98533,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -98242,11 +98559,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -98273,30 +98590,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -98305,15 +98622,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -98346,18 +98663,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -98414,25 +98731,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -98450,19 +98767,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98488,7 +98805,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -98499,10 +98816,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -98536,7 +98853,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -98551,7 +98868,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -98595,7 +98912,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -98605,7 +98922,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -98628,7 +98945,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -98667,7 +98984,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -98688,7 +99005,7 @@ var ts; // ``` insertCaptureThisForNodeIfNeeded(prologue, constructor); } - var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), + var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), /*location*/ constructor.body.statements), /*multiLine*/ true); ts.setTextRange(body, constructor.body); @@ -98717,11 +99034,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -98729,7 +99046,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -98738,10 +99055,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -98830,11 +99147,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -98852,11 +99169,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -98887,10 +99204,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -98900,7 +99217,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -98912,13 +99229,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -98931,7 +99248,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -98945,7 +99262,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -98953,38 +99270,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -98992,11 +99309,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -99015,21 +99332,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -99068,7 +99385,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -99076,7 +99393,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -99090,7 +99407,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -99106,20 +99423,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -99127,7 +99444,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -99150,12 +99467,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -99164,9 +99481,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -99176,17 +99493,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -99201,13 +99518,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, @@ -99225,14 +99542,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -99275,7 +99592,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -99294,7 +99611,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -99315,10 +99632,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -99328,11 +99645,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99363,9 +99680,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -99393,12 +99710,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -99407,10 +99724,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -99427,7 +99744,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -99436,11 +99753,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -99449,7 +99766,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 262144 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -99515,18 +99832,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -99553,16 +99870,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -99582,50 +99899,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -99673,7 +99990,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -99705,18 +100022,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -99732,33 +100049,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -99773,9 +100090,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 524288 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 524288 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -99788,7 +100105,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -99800,7 +100117,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -99816,7 +100133,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -99827,7 +100144,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -99847,7 +100164,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -99891,11 +100208,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -99920,11 +100237,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -99933,7 +100250,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -100046,15 +100363,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -100080,12 +100397,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -100147,7 +100464,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -100156,17 +100473,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -100186,18 +100503,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -100210,7 +100527,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -100219,27 +100536,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -100247,7 +100564,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -100306,19 +100623,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -100340,20 +100657,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -100408,14 +100725,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -100424,7 +100741,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -100443,7 +100760,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -100456,17 +100773,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -100509,11 +100826,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -100586,7 +100903,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -100643,15 +100960,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -100665,7 +100982,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -100677,12 +100994,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -100771,13 +101088,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -100793,12 +101110,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -100806,7 +101123,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -100836,7 +101153,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -100871,15 +101188,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -100891,13 +101208,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -100907,9 +101224,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -100917,16 +101234,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -100937,7 +101254,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -100951,7 +101268,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -100967,10 +101284,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -100983,9 +101300,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -100996,7 +101313,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -101033,9 +101350,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -101052,19 +101369,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -101087,18 +101404,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -101117,9 +101434,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -101179,7 +101496,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -101359,11 +101676,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -101417,7 +101734,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -101440,7 +101757,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -101454,13 +101771,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -101473,30 +101790,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -101511,23 +101828,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -101540,9 +101857,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -101701,13 +102018,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 524288 /* ContainsYield */) { + if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101732,9 +102049,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -101750,7 +102067,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -101762,7 +102079,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -101794,7 +102111,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -101828,13 +102145,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -101851,12 +102168,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -101901,7 +102218,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -101967,7 +102284,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -102156,35 +102473,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -102614,7 +102931,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -102627,7 +102944,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -102759,7 +103076,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -102772,7 +103089,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -102803,7 +103120,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -102849,7 +103166,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -102863,7 +103180,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -102892,7 +103209,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -102902,7 +103219,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -102914,8 +103231,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -102928,7 +103245,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -102941,18 +103258,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -102962,24 +103279,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -102987,7 +103304,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -102997,7 +103314,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -103014,7 +103331,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -103026,7 +103343,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103040,7 +103357,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -103053,7 +103370,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -103063,7 +103380,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -103072,7 +103389,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -103081,14 +103398,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -103100,8 +103417,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -103109,7 +103426,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -103117,7 +103434,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -103214,7 +103531,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -103226,7 +103543,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -103238,8 +103555,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -103252,7 +103569,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -103261,7 +103578,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -103275,7 +103592,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -103284,7 +103601,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -103295,7 +103612,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -103306,7 +103623,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -103315,7 +103632,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -103324,7 +103641,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -103333,7 +103650,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -103342,13 +103659,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -103392,7 +103709,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -103565,8 +103882,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -103576,18 +103893,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -103611,33 +103928,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -103687,8 +104004,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -103699,9 +104016,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -103712,9 +104029,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -103725,9 +104042,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -103738,8 +104055,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -103750,9 +104067,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -103760,7 +104077,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -103787,12 +104104,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -103808,7 +104125,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 4194304 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -103944,7 +104261,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -104029,7 +104346,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -104098,13 +104415,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -104120,23 +104437,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -104145,30 +104462,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4194304 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -104184,24 +104501,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -104227,7 +104544,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -104253,7 +104570,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -104296,7 +104613,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -104323,7 +104640,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -104359,7 +104676,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -104377,7 +104694,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -104398,7 +104715,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -104418,13 +104735,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -104433,7 +104750,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -104480,7 +104797,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -104494,7 +104811,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -104528,7 +104845,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -104538,11 +104855,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -104583,12 +104900,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -104639,7 +104956,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), @@ -104667,7 +104984,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); @@ -104694,7 +105011,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -104752,7 +105069,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -104767,7 +105084,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -104789,7 +105106,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -104801,7 +105118,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -104844,10 +105161,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -104930,8 +105247,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -104976,7 +105293,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -104989,7 +105306,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -105004,7 +105321,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -105016,7 +105333,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -105043,8 +105360,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -105060,7 +105377,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -105085,7 +105402,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -105120,13 +105437,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -105135,9 +105452,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105146,9 +105463,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -105161,16 +105478,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -105259,11 +105576,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -105283,7 +105600,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -105330,7 +105647,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -105452,8 +105769,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 1048576 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -105487,7 +105804,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -105553,7 +105870,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -105577,19 +105894,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -105648,13 +105965,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -105730,7 +106047,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -105783,7 +106100,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -105833,9 +106150,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -105846,7 +106163,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -105898,9 +106215,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -105911,7 +106228,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -105960,10 +106277,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -106057,8 +106374,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -106118,7 +106435,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106130,7 +106447,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -106143,43 +106460,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -106361,30 +106678,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 4194304 /* TransformFlags.ContainsDynamicImport */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -106434,7 +106751,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -106464,7 +106781,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -106480,7 +106797,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -106525,8 +106842,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106542,7 +106859,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -106577,10 +106894,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -106592,7 +106909,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -106627,11 +106944,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -106643,7 +106960,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -106721,7 +107038,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -106764,8 +107081,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -106804,14 +107121,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -106829,7 +107146,7 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause( @@ -106837,16 +107154,16 @@ var ts; /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -106867,12 +107184,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); @@ -106940,7 +107257,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -106949,7 +107266,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -106972,8 +107289,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -107020,7 +107337,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -107075,14 +107392,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107104,14 +107421,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -107135,7 +107452,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -107153,31 +107470,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -107200,7 +107517,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -107217,14 +107534,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -107239,36 +107556,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -107280,9 +107597,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -107305,40 +107622,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -107349,61 +107666,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -107420,7 +107737,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -107469,7 +107786,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -107488,13 +107805,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -107553,7 +107870,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -107562,7 +107879,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -107598,7 +107915,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -107669,10 +107986,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -107695,14 +108012,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -107839,11 +108156,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -107851,7 +108168,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -107864,7 +108181,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = factory.updateParameterDeclaration(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -107881,7 +108198,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -107889,19 +108206,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -107909,12 +108226,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -107925,28 +108242,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -107973,7 +108290,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -108010,7 +108327,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -108036,7 +108353,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -108056,7 +108373,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -108074,34 +108391,44 @@ var ts; if (!decl.importClause) { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // The `importClause` visibility corresponds to the default's visibility. var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, - /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } // Named imports (optionally with visible default) var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Augmentation of export depends on import if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, - /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } // Nothing visible } + function getResolutionModeOverrideForClauseInNightly(assertClause) { + var mode = ts.getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!ts.isNightly()) { + context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } function transformAndReplaceLatePaintedStatements(statements) { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. @@ -108120,7 +108447,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -108178,10 +108505,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -108199,29 +108526,29 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -108231,48 +108558,48 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateSetAccessorDeclaration(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { + case 176 /* SyntaxKind.IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -108280,13 +108607,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -108298,22 +108625,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -108336,7 +108663,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -108346,7 +108673,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -108356,17 +108683,17 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -108374,7 +108701,9 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); + preserveJsDoc(statement, input); + ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -108385,22 +108714,26 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { + if (lateMarkedStatements) { + while (ts.orderedRemoveItem(lateMarkedStatements, input)) + ; + } if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -108421,14 +108754,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -108437,7 +108770,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -108456,10 +108789,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -108470,11 +108803,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, @@ -108495,17 +108828,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -108541,7 +108874,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -108551,10 +108884,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -108596,26 +108929,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -108626,10 +108959,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -108640,7 +108973,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -108648,7 +108981,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -108671,7 +109004,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -108719,12 +109052,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 125951 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 125951 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -108744,13 +109077,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -108760,22 +109093,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 125951 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 125951 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -108784,52 +109117,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -108847,7 +109180,7 @@ var ts; return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; - case ts.ModuleKind.Node12: + case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: return ts.transformNodeModule; default: @@ -108886,35 +109219,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -108968,11 +109301,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -108985,7 +109318,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -109015,13 +109348,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -109045,17 +109378,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -109073,15 +109406,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -109091,23 +109424,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -109117,7 +109450,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -109133,26 +109466,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -109164,9 +109497,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -109179,8 +109512,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -109194,19 +109527,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -109215,8 +109548,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -109228,7 +109561,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -109271,8 +109604,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -109281,12 +109614,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -109300,8 +109633,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -109312,14 +109645,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -109334,7 +109667,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -109373,7 +109706,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -109439,7 +109772,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -109447,7 +109780,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -109456,7 +109789,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -109464,7 +109797,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -109478,11 +109811,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -109498,9 +109831,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -109525,20 +109858,20 @@ var ts; addOutput(buildInfoPath); } function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) { - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -109570,7 +109903,7 @@ var ts; /*@internal*/ function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; /*@internal*/ @@ -109607,17 +109940,17 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + if (ts.isDeclarationFileName(inputFileName)) continue; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -109626,7 +109959,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -109664,13 +109997,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -109805,7 +110138,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SyntaxKind.SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -109816,7 +110149,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -109828,8 +110161,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -109841,6 +110174,7 @@ var ts; else { printer.writeFile(sourceFile, writer, sourceMapGenerator); } + var sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -109852,7 +110186,8 @@ var ts; if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + sourceMapUrlPos = writer.getTextPos(); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { @@ -109864,13 +110199,13 @@ var ts; writer.writeLine(); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -109901,7 +110236,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -109994,8 +110329,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -110081,7 +110416,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -110133,7 +110468,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -110173,20 +110508,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -110242,11 +110577,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -110281,7 +110616,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -110292,7 +110627,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -110302,7 +110637,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -110329,7 +110664,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -110339,7 +110674,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -110378,7 +110713,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -110386,30 +110721,30 @@ var ts; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); + return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile))); } function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -110418,7 +110753,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -110434,12 +110769,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -110447,17 +110782,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -110467,7 +110802,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -110493,346 +110828,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -110844,101 +111179,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -110946,7 +111281,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -110956,7 +111291,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -110986,7 +111321,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -111028,7 +111363,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -111056,7 +111391,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -111086,9 +111421,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -111107,25 +111442,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -111133,7 +111468,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -111148,7 +111483,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -111185,7 +111520,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -111253,7 +111588,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -111363,8 +111698,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -111377,16 +111712,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -111395,10 +111730,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -111431,7 +111766,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -111445,7 +111780,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -111454,13 +111789,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -111470,7 +111805,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -111478,14 +111813,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -111493,7 +111828,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -111512,7 +111847,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -111528,12 +111863,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -111551,29 +111886,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -111599,7 +111934,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -111612,12 +111947,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111630,17 +111965,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -111662,12 +111997,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -111686,22 +112021,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -111726,9 +112061,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -111769,12 +112104,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -111805,11 +112140,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -111820,7 +112155,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -111842,15 +112177,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -111893,10 +112228,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -111917,21 +112252,21 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) - if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -111941,14 +112276,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -111964,45 +112299,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -112011,12 +112346,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -112039,13 +112374,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -112085,40 +112420,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -112127,13 +112462,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -112149,7 +112484,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -112167,7 +112502,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -112204,23 +112539,23 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { return false; } - if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { + if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) { + if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -112235,14 +112570,9 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -112255,11 +112585,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -112274,15 +112604,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -112295,10 +112625,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -112321,13 +112651,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -112349,27 +112679,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112378,12 +112708,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -112394,20 +112724,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112418,37 +112748,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -112458,10 +112788,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -112469,26 +112799,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -112500,7 +112830,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -112511,7 +112841,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -112530,7 +112860,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -112543,7 +112873,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -112572,7 +112902,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -112603,17 +112933,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112624,30 +112954,31 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { var emitAsSingleStatement = statements.length === 1 && ( // treat synthesized nodes as located on the same line for emit purposes - ts.nodeIsSynthesized(parentNode) || + !currentSourceFile || + ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -112655,15 +112986,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -112683,7 +113014,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -112700,7 +113031,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -112731,12 +113062,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -112770,13 +113101,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -112795,7 +113126,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -112813,14 +113144,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -112868,16 +113199,14 @@ var ts; function emitSourceFile(node) { writeLine(); var statements = node.statements; - if (emitBodyWithDetachedComments) { - // Emit detached comment if there are no prologue directives or if the first node is synthesized. - // The synthesized node will have no leading comment so some comments may be missed. - var shouldEmitDetachedComment = statements.length === 0 || - !ts.isPrologueDirective(statements[0]) || - ts.nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -112903,21 +113232,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -112925,28 +113254,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { var directive = types_24[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -112957,22 +113286,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -112993,7 +113322,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -113014,7 +113343,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -113107,7 +113436,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 262656 /* Modifiers */); + emitList(node, modifiers, 262656 /* ListFormat.Modifiers */); writeSpace(); } } @@ -113121,7 +113450,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -113151,7 +113480,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -113159,7 +113488,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -113168,19 +113497,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -113201,32 +113530,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -113242,11 +113571,11 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -113255,7 +113584,7 @@ var ts; } return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -113266,28 +113595,28 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } else { ts.Debug.type(children); // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -113298,7 +113627,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -113310,7 +113639,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -113320,14 +113649,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -113350,11 +113679,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (hasTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -113366,11 +113695,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -113379,14 +113708,14 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -113471,7 +113800,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -113521,13 +113850,13 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -113547,11 +113876,11 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild_1.kind === 11 /* JsxText */) { + if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { @@ -113564,18 +113893,18 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); } @@ -113589,7 +113918,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -113598,18 +113927,18 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, children, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -113620,7 +113949,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -113649,14 +113978,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -113665,14 +113994,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -113682,7 +114011,7 @@ var ts; if (ts.getStartsOnNewLine(node2)) { return 1; } - if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); } @@ -113692,10 +114021,10 @@ var ts; } function isEmptyBlock(block) { return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -113704,41 +114033,48 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return generateName(node); } - else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { - return ts.idText(node); - } - else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (ts.isStringLiteral(node) && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + var sourceFile = currentSourceFile; // const needed for control flow + var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node); + if (ts.isMemberName(node)) { + if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) { + return ts.idText(node); + } } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + else { + ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary + if (!canUseSourceFile) { + return node.text; + } + } + return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -113749,7 +114085,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -113765,84 +114101,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -113851,12 +114187,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -113875,7 +114211,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -113914,7 +114250,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -113928,7 +114264,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -113938,12 +114274,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -113975,7 +114311,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -114029,48 +114365,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -114086,7 +114422,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -114097,7 +114433,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -114110,7 +114446,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -114118,7 +114454,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -114132,25 +114468,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -114160,7 +114496,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -114169,18 +114505,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -114198,25 +114534,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -114292,7 +114628,7 @@ var ts; return true; } function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); @@ -114305,7 +114641,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -114319,7 +114655,7 @@ var ts; forEachTrailingCommentToEmit(pos, emitTrailingComment); } function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { @@ -114341,15 +114677,19 @@ var ts; exitComment(); } function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!currentSourceFile) + return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); @@ -114382,6 +114722,8 @@ var ts; return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { + if (!currentSourceFile) + return; // get the leading comments from detachedPos var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { @@ -114393,7 +114735,7 @@ var ts; ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -114404,7 +114746,7 @@ var ts; } } function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentSourceFile.text, commentPos)) + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); @@ -114416,7 +114758,7 @@ var ts; * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps function getParsedSourceMap(node) { @@ -114426,7 +114768,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -114444,12 +114786,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -114459,11 +114801,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -114516,17 +114858,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -114557,23 +114899,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -114939,7 +115281,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -114948,11 +115290,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -114962,7 +115304,7 @@ var ts; if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored - if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { + if (ts.isDeclarationFileName(fileOrDirectoryPath)) { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; @@ -114974,9 +115316,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -115009,7 +115351,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -115044,36 +115386,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -115083,16 +115425,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -115304,7 +115646,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -115315,7 +115657,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -115331,7 +115673,11 @@ var ts; return newValue; }; if (originalWriteFile) { - host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) { + host.writeFile = function (fileName, data) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); @@ -115345,7 +115691,7 @@ var ts; sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } // directoryExists @@ -115399,12 +115745,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -115492,9 +115838,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -115508,7 +115854,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -115571,7 +115917,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115677,7 +116023,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -115857,11 +116203,11 @@ var ts; */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { - case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; @@ -115911,7 +116257,6 @@ var ts; ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -116017,7 +116362,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -116098,16 +116443,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -116135,7 +116480,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -116144,19 +116489,19 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId }); } ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -116278,14 +116623,15 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, + writeFile: writeFile, }; onProgramCreateComplete(); // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -116297,17 +116643,52 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; + function addResolutionDiagnostics(list) { + if (!list) + return; + for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { + var elem = list_3[_i]; + programDiagnostics.add(elem); + } + } + function pullDiagnosticsFromCache(names, containingFile) { + var _a; + if (!moduleResolutionCache) + return; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + var containingDir = ts.getDirectoryPath(containingFileName); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var n = names_4[_i]; + // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less + var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + var name = typeof n === "string" ? n : n.fileName; + i++; + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + if (ts.isExternalModuleNameRelative(name)) + continue; + var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -116316,7 +116697,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -116326,7 +116707,7 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) + if (redirect || !ts.isDeclarationFileName(file.originalFileName)) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case @@ -116398,7 +116779,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -116553,22 +116934,22 @@ var ts; function tryReuseStructureFromOldProgram() { var _a; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -116576,12 +116957,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -116596,7 +116977,7 @@ var ts; ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; @@ -116605,7 +116986,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -116613,7 +116994,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -116630,9 +117011,9 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } @@ -116640,49 +117021,49 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); @@ -116703,7 +117084,7 @@ var ts; // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -116714,18 +117095,18 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping @@ -116756,7 +117137,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -116775,7 +117156,7 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, getSymlinkCache: getSymlinkCache, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + writeFile: writeFileCallback || writeFile, isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { @@ -116795,9 +117176,12 @@ var ts; getFileIncludeReasons: program.getFileIncludeReasons, }; } + function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -116849,7 +117233,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -116969,7 +117353,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -116977,8 +117361,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -117057,22 +117441,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -117080,65 +117464,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -117147,53 +117531,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 124 /* StaticKeyword */) { + if (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -117206,27 +117590,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -117296,20 +117680,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -117340,7 +117724,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -117362,7 +117746,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -117417,7 +117801,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -117532,7 +117916,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -117717,7 +118101,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -117727,7 +118111,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -117760,13 +118144,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -117805,14 +118189,14 @@ var ts; var fileName = ts.toFileNameLowerCase(ref.fileName); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); var mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { - programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { + programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, }); } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -117871,7 +118255,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -117891,7 +118275,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -117938,7 +118322,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -117999,7 +118383,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -118139,19 +118523,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -118168,7 +118552,7 @@ var ts; } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && - ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -118190,7 +118574,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -118212,7 +118596,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -118226,7 +118610,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -118234,12 +118618,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -118318,7 +118702,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -118557,7 +118941,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -118567,16 +118951,16 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -118677,12 +119061,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -118735,7 +119119,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -118831,17 +119215,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -118860,7 +119244,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -118875,7 +119259,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -118900,13 +119284,9 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - var manyToManyPathMapCount = 0; function createManyToManyPathMap() { function create(forward, reverse, deleted) { - var version = 0; var map = { - id: manyToManyPathMapCount++, - version: function () { return version; }, clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, @@ -118922,30 +119302,29 @@ var ts; } set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); forward.delete(k); - version++; return true; }, set: function (k, vSet) { - var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + deleted === null || deleted === void 0 ? void 0 : deleted.delete(k); var existingVSet = forward.get(k); forward.set(k, vSet); existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(function (v) { if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } return map; }, + clear: function () { + forward.clear(); + reverse.clear(); + deleted === null || deleted === void 0 ? void 0 : deleted.clear(); + } }; return map; } @@ -118960,11 +119339,10 @@ var ts; } set.add(v); } - function deleteFromMultimap(map, k, v, removeEmpty) { - if (removeEmpty === void 0) { removeEmpty = true; } + function deleteFromMultimap(map, k, v) { var set = map.get(k); if (set === null || set === void 0 ? void 0 : set.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -119193,7 +119571,7 @@ var ts; /*forceDtsEmit*/ true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -119243,6 +119621,7 @@ var ts; } } } + BuilderState.updateExportedModules = updateExportedModules; /** * Updates the exported modules from cache into state's exported modules map * This should be called whenever it is safe to commit the state of the builder @@ -119251,20 +119630,6 @@ var ts; var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - var cacheId = exportedModulesMapCache.id; - var cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - // If this is the same cache at the same version as last time this BuilderState - // was updated, there's no need to update again - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } @@ -119513,7 +119878,7 @@ var ts; } else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -119598,7 +119963,8 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash) { + function getNextAffectedFile(state, cancellationToken, computeHash, host) { + var _a; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -119609,7 +119975,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -119621,6 +119987,7 @@ var ts; ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); state.currentAffectedFilesSignatures.clear(); ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); state.affectedFiles = undefined; } // Get next changed file @@ -119650,6 +120017,11 @@ var ts; state.seenAffectedFiles = new ts.Set(); } } + function clearAffectedFilesPendingEmit(state) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } /** * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet */ @@ -119669,49 +120041,48 @@ var ts; } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } + function removeDiagnosticsOfLibraryFiles(state) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var program_1 = ts.Debug.checkDefined(state.program); + var options_2 = program_1.getCompilerOptions(); + ts.forEach(program_1.getSourceFiles(), function (f) { + return program_1.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2, program_1) && + removeSemanticDiagnosticsOf(state, f.resolvedPath); + }); + } + } /** * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.checkDefined(state.program); - var options_2 = program_1.getCompilerOptions(); - ts.forEach(program_1.getSourceFiles(), function (f) { - return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2, program_1) && - removeSemanticDiagnosticsOf(state, f.resolvedPath); - }); - } + removeDiagnosticsOfLibraryFiles(state); // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } - else { - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); - } - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); - } + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) + return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -119722,11 +120093,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, - /* useFileVersionAsSignature */ true); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -119748,16 +120118,41 @@ var ts; var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } + function forEachKeyOfExportedModulesMap(state, filePath, fn) { + // Go through exported modules from cache first + var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); + var result = keys && ts.forEachKey(keys, fn); + if (result) + return result; + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + keys = state.exportedModulesMap.getKeys(filePath); + return keys && ts.forEachKey(keys, function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? + fn(exportedFromPath) : + undefined; + }); + } + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + var _a; + if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) + return false; + // Every file needs to be handled + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + removeDiagnosticsOfLibraryFiles(state); + return true; + } /** - * Iterate on referencing modules that export entities from affected file + * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - var _a, _b; + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; - } if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself @@ -119770,7 +120165,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -119782,56 +120179,38 @@ var ts; var seenFileAndExportsOfFile = new ts.Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + return true; + var references = state.referencedMap.getKeys(exportedFromPath); + return references && ts.forEachKey(references, function (filePath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + }); }); } /** - * Iterate on files referencing referencedPath + * handle dts and semantic diagnostics on file and iterate on anything that exports this file + * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { var _a; - (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { - return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); - }); - } - /** - * fn on file and iterate on anything that exports this file - */ - function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { - var _a, _b, _c; - if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - fn(state, filePath); + if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) + return undefined; + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - }); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { - var _a; - // If the cache had an updated value, skip - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) - (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file - fn(state, referencingFilePath); - } // Dont add to seen since this is not yet done with the export removal - ); + handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal + state, referencingFilePath, cancellationToken, computeHash, host); + }); + return undefined; } /** * This is called after completing operation on the next affected file. @@ -119920,13 +120299,18 @@ var ts; var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + // If file version is same as signature, dont serialize signature + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // If file info only contains version and signature and both are same we can just write string value.version : - actualSignature !== undefined ? + actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo signature === undefined ? + // If we havent computed signature, use fileInfo as is value : + // Serialize fileInfo with new updated signature { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // Signature of the FileInfo is undefined, serialize it as false { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; @@ -120171,8 +120555,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -120185,7 +120569,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -120202,7 +120586,43 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + } + function getWriteFileUpdatingSignatureCallback(writeFile) { + return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { + var _a; + if (ts.isDeclarationFileName(fileName)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; + if (signature === file.version) { + var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { // Update it + if (host.storeFilesChangingSignatureDuringEmit) + (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); + if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { + state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) + ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) + writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else + state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; } /** * Emits the JavaScript and declaration files. @@ -120216,56 +120636,52 @@ var ts; * in that order would be used to write the files */ function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var restorePendingEmitOnHandlingNoEmitSuccess = false; - var savedAffectedFilesPendingEmit; - var savedAffectedFilesPendingEmitKind; - var savedAffectedFilesPendingEmitIndex; - // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors - // This ensures pending files to emit is updated in tsbuildinfo - // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit) - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !ts.outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } + var _a; if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } // Emit only affected files if using builder for emit - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - // Emit and report any errors we ran into. - var sourceMaps = []; - var emitSkipped = false; - var diagnostics = void 0; - var emittedFiles = []; - var affectedEmitResult = void 0; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + // Emit and report any errors we ran into. + var sourceMaps = []; + var emitSkipped = false; + var diagnostics = void 0; + var emittedFiles = []; + var affectedEmitResult = void 0; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped: emitSkipped, + diagnostics: diagnostics || ts.emptyArray, + emittedFiles: emittedFiles, + sourceMaps: sourceMaps + }; + } + // In non Emit builder, clear affected files pending emit + else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) { + ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + // State can clear affected files pending emit if + if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared + // If every file pending emit is pending on only dts emit + || ts.every(state.affectedFilesPendingEmit, function (path, index) { + return index < state.affectedFilesPendingEmitIndex || + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; + })) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped: emitSkipped, - diagnostics: diagnostics || ts.emptyArray, - emittedFiles: emittedFiles, - sourceMaps: sourceMaps - }; } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** * Return the semantic diagnostics for the next affected file or undefined if iteration is complete @@ -120273,7 +120689,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { // Done return undefined; @@ -120285,7 +120701,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -120497,7 +120913,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -120554,7 +120970,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); @@ -120709,8 +121125,8 @@ var ts; !!redirectedReference; var seenNamesInFile = ts.createModeAwareCache(); var i = 0; - for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { - var entry = names_4[_i]; + for (var _i = 0, names_5 = names; _i < names_5.length; _i++) { + var entry = names_5[_i]; var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase(); // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant // they require calculating the mode for a given import from it's position in the resolution table, since a given @@ -120854,7 +121270,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -121031,7 +121447,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -121042,7 +121458,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -121182,7 +121598,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -121250,33 +121666,33 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { var _a; - if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { return false; } @@ -121320,14 +121736,14 @@ var ts; if (options === void 0) { options = {}; } var info = getInfo(importingSourceFile.path, host); var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); }); } moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) { if (options === void 0) { options = {}; } var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { @@ -121384,7 +121800,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -121403,7 +121819,7 @@ var ts; var relativeSpecifiers; for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { var modulePath = modulePaths_1[_i]; - var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", @@ -121445,7 +121861,7 @@ var ts; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -121459,10 +121875,10 @@ var ts; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -121496,7 +121912,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -121504,7 +121920,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -121675,11 +122091,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -121720,23 +122136,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -121763,9 +122179,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -121796,7 +122212,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) { + function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) { var path = _a.path, isRedirect = _a.isRedirect; var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { @@ -121810,8 +122226,9 @@ var ts; var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; - var moduleFileNameForExtensionless = void 0; + var moduleFileName = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; @@ -121828,12 +122245,12 @@ var ts; isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) - moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) + moduleFileName = moduleFileToTry; // try with next level of directory packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -121861,7 +122278,7 @@ var ts; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); - if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` @@ -121885,13 +122302,13 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Ending.Minimal */, options), versionPaths.paths); if (fromPaths !== undefined) { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name - var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -121899,24 +122316,21 @@ var ts; } } } - return { moduleFileToTry: moduleFileToTry }; - } - function getExtensionlessFileName(path) { - // We still have a file name - remove the extension - var fullModulePathWithoutExtension = ts.removeFileExtension(path); - // If the file is /index, it can be imported by its directory name - // IFF there is not _also_ a file by the same name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + // No package.json exists; an index.js will still resolve as the package name + var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath }; + } } - return fullModulePathWithoutExtension; + return { moduleFileToTry: moduleFileToTry }; } } function tryGetAnyFileFromPath(host, path) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -121931,18 +122345,24 @@ var ts; return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } - function removeExtensionAndIndexPostFix(fileName, ending, options) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + function removeExtensionAndIndexPostFix(fileName, ending, options, host) { + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: - return ts.removeSuffix(noExtension, "/index"); - case 1 /* Index */: + case 0 /* Ending.Minimal */: + var withoutIndex = ts.removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + // Can't remove index if there's a file by the same name as the directory. + // Probably more callers should pass `host` so we can determine this? + return noExtension; + } + return withoutIndex; + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -121950,28 +122370,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -122053,8 +122473,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -122062,8 +122482,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -122086,7 +122506,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -122119,7 +122539,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -122132,7 +122552,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -122155,7 +122575,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -122182,9 +122602,9 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; @@ -122217,14 +122637,14 @@ var ts; var configFile = program.getCompilerOptions().configFile; if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs)) return undefined; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -122233,7 +122653,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -122357,7 +122777,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -122457,6 +122877,7 @@ var ts; createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -122516,6 +122937,7 @@ var ts; createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } ts.createProgramHost = createProgramHost; @@ -122604,6 +123026,7 @@ var ts; var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -122686,7 +123109,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -122842,10 +123265,10 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -123006,7 +123429,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -123066,7 +123489,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -123107,7 +123530,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -123348,7 +123771,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -123393,9 +123816,6 @@ var ts; function newer(date1, date2) { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); - } /*@internal*/ function isCircularBuildOrder(buildOrder) { return !!buildOrder && !!buildOrder.buildOrder; @@ -123411,8 +123831,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -123958,7 +124378,7 @@ var ts; outputFiles.forEach(function (_a) { var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; var priorChangeTime; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && ts.isDeclarationFileName(name)) { // Check for unchanged .d.ts files if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); @@ -124187,7 +124607,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -124216,7 +124636,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -124244,7 +124664,7 @@ var ts; if (!host.fileExists(inputFile)) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (!force) { @@ -124299,7 +124719,7 @@ var ts; // In addition to file timestamps, we also keep track of when a .d.ts file // had its file touched but not had its contents changed - this allows us // to skip a downstream typecheck - if (isDeclarationFile(output)) { + if (ts.isDeclarationFileName(output)) { var outputModifiedTime = ts.getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -124453,7 +124873,7 @@ var ts; reportVerbose = false; reportStatus(state, verboseMessage, proj.options.configFilePath); } - if (isDeclarationFile(file)) { + if (ts.isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); @@ -124603,7 +125023,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -124706,7 +125126,7 @@ var ts; if (!state.watch || !state.lastCachedPackageJsonLookups) return; ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { - createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, onDeleteValue: ts.closeFileWatcher, }); } @@ -124941,7 +125361,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -124952,7 +125372,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -125005,7 +125425,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -125078,7 +125498,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -125092,7 +125512,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -125101,7 +125521,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -125123,7 +125543,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -125151,7 +125571,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -125167,7 +125587,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -125186,12 +125606,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -125217,7 +125637,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -125245,16 +125665,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -125262,20 +125682,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -125286,17 +125706,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -125321,7 +125741,7 @@ var ts; } catch (e) { if (log.isEnabled()) { - log.writeLine("Failed to resolve " + packageName + " in folder '" + cachePath + "': " + e.message); + log.writeLine("Failed to resolve ".concat(packageName, " in folder '").concat(cachePath, "': ").concat(e.message)); } return undefined; } @@ -125342,7 +125762,7 @@ var ts; var sliceStart = packageNames.length - remaining; var command, toSlice = remaining; while (true) { - command = npmPath + " install --ignore-scripts " + (toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ") + " --save-dev --user-agent=\"typesInstaller/" + tsVersion + "\""; + command = "".concat(npmPath, " install --ignore-scripts ").concat((toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" "), " --save-dev --user-agent=\"typesInstaller/").concat(tsVersion, "\""); if (command.length < 8000) { break; } @@ -125355,13 +125775,13 @@ var ts; var expectedPos = str.length - suffix.length; return expectedPos >= 0 && (str.indexOf(suffix, expectedPos) === expectedPos || - (!caseSensitive && ts.compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* EqualTo */)); + (!caseSensitive && ts.compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* Comparison.EqualTo */)); } function isPackageOrBowerJson(fileName, caseSensitive) { return endsWith(fileName, "/package.json", caseSensitive) || endsWith(fileName, "/bower.json", caseSensitive); } function sameFiles(a, b, caseSensitive) { - return a === b || (!caseSensitive && ts.compareStringsCaseInsensitive(a, b) === 0 /* EqualTo */); + return a === b || (!caseSensitive && ts.compareStringsCaseInsensitive(a, b) === 0 /* Comparison.EqualTo */); } var ProjectWatcherType; (function (ProjectWatcherType) { @@ -125369,12 +125789,12 @@ var ts; ProjectWatcherType["DirectoryWatcher"] = "DirectoryWatcher"; })(ProjectWatcherType || (ProjectWatcherType = {})); function getDetailWatchInfo(projectName, watchers) { - return "Project: " + projectName + " watcher already invoked: " + watchers.isInvoked; + return "Project: ".concat(projectName, " watcher already invoked: ").concat(watchers.isInvoked); } var TypingsInstaller = /** @class */ (function () { function TypingsInstaller(installTypingHost, globalCachePath, safeListPath, typesMapLocation, throttleLimit, log) { - var _this = this; if (log === void 0) { log = nullLog; } + var _this = this; this.installTypingHost = installTypingHost; this.globalCachePath = globalCachePath; this.safeListPath = safeListPath; @@ -125393,7 +125813,7 @@ var ts; this.globalCachePackageJsonPath = ts.combinePaths(globalCachePath, "package.json"); var isLoggingEnabled = this.log.isEnabled(); if (isLoggingEnabled) { - this.log.writeLine("Global cache location '" + globalCachePath + "', safe file path '" + safeListPath + "', types map path " + typesMapLocation); + this.log.writeLine("Global cache location '".concat(globalCachePath, "', safe file path '").concat(safeListPath, "', types map path ").concat(typesMapLocation)); } this.watchFactory = ts.getWatchFactory(this.installTypingHost, isLoggingEnabled ? ts.WatchLogLevel.Verbose : ts.WatchLogLevel.None, function (s) { return _this.log.writeLine(s); }, getDetailWatchInfo); this.processCacheLocation(this.globalCachePath); @@ -125403,30 +125823,30 @@ var ts; }; TypingsInstaller.prototype.closeWatchers = function (projectName) { if (this.log.isEnabled()) { - this.log.writeLine("Closing file watchers for project '" + projectName + "'"); + this.log.writeLine("Closing file watchers for project '".concat(projectName, "'")); } var watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { - this.log.writeLine("No watchers are registered for project '" + projectName + "'"); + this.log.writeLine("No watchers are registered for project '".concat(projectName, "'")); } return; } ts.clearMap(watchers, ts.closeFileWatcher); this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { - this.log.writeLine("Closing file watchers for project '" + projectName + "' - done."); + this.log.writeLine("Closing file watchers for project '".concat(projectName, "' - done.")); } }; TypingsInstaller.prototype.install = function (req) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("Got install request " + JSON.stringify(req)); + this.log.writeLine("Got install request ".concat(JSON.stringify(req))); } // load existing typing information from the cache if (req.cachePath) { if (this.log.isEnabled()) { - this.log.writeLine("Request specifies cache path '" + req.cachePath + "', loading cached information..."); + this.log.writeLine("Request specifies cache path '".concat(req.cachePath, "', loading cached information...")); } this.processCacheLocation(req.cachePath); } @@ -125435,7 +125855,7 @@ var ts; } var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry); if (this.log.isEnabled()) { - this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult)); + this.log.writeLine("Finished typings discovery: ".concat(JSON.stringify(discoverTypingsResult))); } // start watching files this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch, req.projectRootPath, req.watchOptions); @@ -125455,17 +125875,17 @@ var ts; if (this.typesMapLocation) { var safeListFromMap = ts.JsTyping.loadTypesMap(this.installTypingHost, this.typesMapLocation); if (safeListFromMap) { - this.log.writeLine("Loaded safelist from types map file '" + this.typesMapLocation + "'"); + this.log.writeLine("Loaded safelist from types map file '".concat(this.typesMapLocation, "'")); this.safeList = safeListFromMap; return; } - this.log.writeLine("Failed to load safelist from types map file '" + this.typesMapLocation + "'"); + this.log.writeLine("Failed to load safelist from types map file '".concat(this.typesMapLocation, "'")); } this.safeList = ts.JsTyping.loadSafeList(this.installTypingHost, this.safeListPath); }; TypingsInstaller.prototype.processCacheLocation = function (cacheLocation) { if (this.log.isEnabled()) { - this.log.writeLine("Processing cache location '" + cacheLocation + "'"); + this.log.writeLine("Processing cache location '".concat(cacheLocation, "'")); } if (this.knownCachesSet.has(cacheLocation)) { if (this.log.isEnabled()) { @@ -125476,14 +125896,14 @@ var ts; var packageJson = ts.combinePaths(cacheLocation, "package.json"); var packageLockJson = ts.combinePaths(cacheLocation, "package-lock.json"); if (this.log.isEnabled()) { - this.log.writeLine("Trying to find '" + packageJson + "'..."); + this.log.writeLine("Trying to find '".concat(packageJson, "'...")); } if (this.installTypingHost.fileExists(packageJson) && this.installTypingHost.fileExists(packageLockJson)) { var npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); // TODO: GH#18217 var npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); // TODO: GH#18217 if (this.log.isEnabled()) { - this.log.writeLine("Loaded content of '" + packageJson + "': " + JSON.stringify(npmConfig)); - this.log.writeLine("Loaded content of '" + packageLockJson + "'"); + this.log.writeLine("Loaded content of '".concat(packageJson, "': ").concat(JSON.stringify(npmConfig))); + this.log.writeLine("Loaded content of '".concat(packageLockJson, "'")); } if (npmConfig.devDependencies && npmLock.dependencies) { for (var key in npmConfig.devDependencies) { @@ -125507,11 +125927,11 @@ var ts; continue; } if (this.log.isEnabled()) { - this.log.writeLine("New typing for package " + packageName + " from '" + typingFile + "' conflicts with existing typing file '" + existingTypingFile + "'"); + this.log.writeLine("New typing for package ".concat(packageName, " from '").concat(typingFile, "' conflicts with existing typing file '").concat(existingTypingFile, "'")); } } if (this.log.isEnabled()) { - this.log.writeLine("Adding entry into typings cache: '" + packageName + "' => '" + typingFile + "'"); + this.log.writeLine("Adding entry into typings cache: '".concat(packageName, "' => '").concat(typingFile, "'")); } var info = ts.getProperty(npmLock.dependencies, key); var version_1 = info && info.version; @@ -125524,7 +125944,7 @@ var ts; } } if (this.log.isEnabled()) { - this.log.writeLine("Finished processing cache location '" + cacheLocation + "'"); + this.log.writeLine("Finished processing cache location '".concat(cacheLocation, "'")); } this.knownCachesSet.add(cacheLocation); }; @@ -125534,11 +125954,11 @@ var ts; var typingKey = ts.mangleScopedPackageName(typing); if (_this.missingTypingsSet.has(typingKey)) { if (_this.log.isEnabled()) - _this.log.writeLine("'" + typing + "':: '" + typingKey + "' is in missingTypingsSet - skipping..."); + _this.log.writeLine("'".concat(typing, "':: '").concat(typingKey, "' is in missingTypingsSet - skipping...")); return undefined; } var validationResult = ts.JsTyping.validatePackageName(typing); - if (validationResult !== 0 /* Ok */) { + if (validationResult !== 0 /* JsTyping.NameValidationResult.Ok */) { // add typing name to missing set so we won't process it again _this.missingTypingsSet.add(typingKey); if (_this.log.isEnabled()) @@ -125547,12 +125967,12 @@ var ts; } if (!_this.typesRegistry.has(typingKey)) { if (_this.log.isEnabled()) - _this.log.writeLine("'" + typing + "':: Entry for package '" + typingKey + "' does not exist in local types registry - skipping..."); + _this.log.writeLine("'".concat(typing, "':: Entry for package '").concat(typingKey, "' does not exist in local types registry - skipping...")); return undefined; } if (_this.packageNameToTypingLocation.get(typingKey) && ts.JsTyping.isTypingUpToDate(_this.packageNameToTypingLocation.get(typingKey), _this.typesRegistry.get(typingKey))) { if (_this.log.isEnabled()) - _this.log.writeLine("'" + typing + "':: '" + typingKey + "' already has an up-to-date typing - skipping..."); + _this.log.writeLine("'".concat(typing, "':: '").concat(typingKey, "' already has an up-to-date typing - skipping...")); return undefined; } return typingKey; @@ -125561,11 +125981,11 @@ var ts; TypingsInstaller.prototype.ensurePackageDirectoryExists = function (directory) { var npmConfigPath = ts.combinePaths(directory, "package.json"); if (this.log.isEnabled()) { - this.log.writeLine("Npm config file: " + npmConfigPath); + this.log.writeLine("Npm config file: ".concat(npmConfigPath)); } if (!this.installTypingHost.fileExists(npmConfigPath)) { if (this.log.isEnabled()) { - this.log.writeLine("Npm config file: '" + npmConfigPath + "' is missing, creating new one..."); + this.log.writeLine("Npm config file: '".concat(npmConfigPath, "' is missing, creating new one...")); } this.ensureDirectoryExists(directory, this.installTypingHost); this.installTypingHost.writeFile(npmConfigPath, '{ "private": true }'); @@ -125574,7 +125994,7 @@ var ts; TypingsInstaller.prototype.installTypings = function (req, cachePath, currentlyCachedTypings, typingsToInstall) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); + this.log.writeLine("Installing typings ".concat(JSON.stringify(typingsToInstall))); } var filteredTypings = this.filterTypings(typingsToInstall); if (filteredTypings.length === 0) { @@ -125601,7 +126021,7 @@ var ts; try { if (!ok) { if (_this.log.isEnabled()) { - _this.log.writeLine("install request failed, marking packages as missing to prevent repeated requests: " + JSON.stringify(filteredTypings)); + _this.log.writeLine("install request failed, marking packages as missing to prevent repeated requests: ".concat(JSON.stringify(filteredTypings))); } for (var _i = 0, filteredTypings_1 = filteredTypings; _i < filteredTypings_1.length; _i++) { var typing = filteredTypings_1[_i]; @@ -125611,7 +126031,7 @@ var ts; } // TODO: watch project directory if (_this.log.isEnabled()) { - _this.log.writeLine("Installed typings " + JSON.stringify(scopedTypings)); + _this.log.writeLine("Installed typings ".concat(JSON.stringify(scopedTypings))); } var installedTypingFiles = []; for (var _a = 0, filteredTypings_2 = filteredTypings; _a < filteredTypings_2.length; _a++) { @@ -125623,13 +126043,13 @@ var ts; } // packageName is guaranteed to exist in typesRegistry by filterTypings var distTags = _this.typesRegistry.get(packageName); - var newVersion = new ts.Version(distTags["ts" + ts.versionMajorMinor] || distTags[_this.latestDistTag]); + var newVersion = new ts.Version(distTags["ts".concat(ts.versionMajorMinor)] || distTags[_this.latestDistTag]); var newTyping = { typingLocation: typingFile, version: newVersion }; _this.packageNameToTypingLocation.set(packageName, newTyping); installedTypingFiles.push(typingFile); } if (_this.log.isEnabled()) { - _this.log.writeLine("Installed typing files " + JSON.stringify(installedTypingFiles)); + _this.log.writeLine("Installed typing files ".concat(JSON.stringify(installedTypingFiles))); } _this.sendResponse(_this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles))); } @@ -125683,9 +126103,9 @@ var ts; return; } if (isLoggingEnabled) { - _this.log.writeLine(projectWatcherType + ":: Added:: WatchInfo: " + path); + _this.log.writeLine("".concat(projectWatcherType, ":: Added:: WatchInfo: ").concat(path)); } - var watcher = projectWatcherType === "FileWatcher" /* FileWatcher */ ? + var watcher = projectWatcherType === "FileWatcher" /* ProjectWatcherType.FileWatcher */ ? _this.watchFactory.watchFile(path, function () { if (!watchers.isInvoked) { watchers.isInvoked = true; @@ -125693,7 +126113,7 @@ var ts; } }, ts.PollingInterval.High, options, projectName, watchers) : _this.watchFactory.watchDirectory(path, function (f) { - if (watchers.isInvoked || !ts.fileExtensionIs(f, ".json" /* Json */)) { + if (watchers.isInvoked || !ts.fileExtensionIs(f, ".json" /* Extension.Json */)) { return; } if (isPackageOrBowerJson(f, _this.installTypingHost.useCaseSensitiveFileNames) && @@ -125701,10 +126121,10 @@ var ts; watchers.isInvoked = true; _this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate }); } - }, 1 /* Recursive */, options, projectName, watchers); + }, 1 /* WatchDirectoryFlags.Recursive */, options, projectName, watchers); watchers.set(canonicalPath, isLoggingEnabled ? { close: function () { - _this.log.writeLine(projectWatcherType + ":: Closed:: WatchInfo: " + path); + _this.log.writeLine("".concat(projectWatcherType, ":: Closed:: WatchInfo: ").concat(path)); watcher.close(); } } : watcher); @@ -125714,7 +126134,7 @@ var ts; var file = files_1[_i]; if (file.endsWith("/package.json") || file.endsWith("/bower.json")) { // package.json or bower.json exists, watch the file to detect changes and update typings - createProjectWatcher(file, "FileWatcher" /* FileWatcher */); + createProjectWatcher(file, "FileWatcher" /* ProjectWatcherType.FileWatcher */); continue; } // path in projectRoot, watch project root @@ -125722,21 +126142,21 @@ var ts; var subDirectory = file.indexOf(ts.directorySeparator, projectRootPath.length + 1); if (subDirectory !== -1) { // Watch subDirectory - createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); } else { // Watch the directory itself - createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(file, "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); } continue; } // path in global cache, watch global cache if (ts.containsPath(this.globalCachePath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) { - createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); continue; } // watch node_modules or bower_components - createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(file, "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); } // Remove unused watches toRemove.forEach(function (watch, path) { @@ -125779,7 +126199,7 @@ var ts; typingsInstaller.TypingsInstaller = TypingsInstaller; /* @internal */ function typingsName(packageName) { - return "@types/" + packageName + "@ts" + ts.versionMajorMinor; + return "@types/".concat(packageName, "@ts").concat(ts.versionMajorMinor); } typingsInstaller.typingsName = typingsName; })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); @@ -125804,7 +126224,7 @@ var ts; if (typeof _this.logFile !== "string") return; try { - fs.appendFileSync(_this.logFile, "[" + server.nowString() + "] " + text + ts.sys.newLine); + fs.appendFileSync(_this.logFile, "[".concat(server.nowString(), "] ").concat(text).concat(ts.sys.newLine)); } catch (e) { _this.logFile = undefined; @@ -125820,7 +126240,7 @@ var ts; return npmPath; } if (host.fileExists(npmPath)) { - return "\"" + npmPath + "\""; + return "\"".concat(npmPath, "\""); } } return "npm"; @@ -125828,7 +126248,7 @@ var ts; function loadTypesRegistryFile(typesRegistryFilePath, host, log) { if (!host.fileExists(typesRegistryFilePath)) { if (log.isEnabled()) { - log.writeLine("Types registry file '" + typesRegistryFilePath + "' does not exist"); + log.writeLine("Types registry file '".concat(typesRegistryFilePath, "' does not exist")); } return new ts.Map(); } @@ -125838,14 +126258,14 @@ var ts; } catch (e) { if (log.isEnabled()) { - log.writeLine("Error when loading types registry file '" + typesRegistryFilePath + "': " + e.message + ", " + e.stack); + log.writeLine("Error when loading types registry file '".concat(typesRegistryFilePath, "': ").concat(e.message, ", ").concat(e.stack)); } return new ts.Map(); } } var typesRegistryPackageName = "types-registry"; function getTypesRegistryFileLocation(globalTypingsCacheLocation) { - return ts.combinePaths(ts.normalizeSlashes(globalTypingsCacheLocation), "node_modules/" + typesRegistryPackageName + "/index.json"); + return ts.combinePaths(ts.normalizeSlashes(globalTypingsCacheLocation), "node_modules/".concat(typesRegistryPackageName, "/index.json")); } var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); @@ -125853,27 +126273,27 @@ var ts; var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), typesMapLocation ? ts.toPath(typesMapLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typesMap.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; _this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0], validateDefaultNpmLocation, _this.installTypingHost); if (ts.stringContains(_this.npmPath, " ") && _this.npmPath[0] !== "\"") { - _this.npmPath = "\"" + _this.npmPath + "\""; + _this.npmPath = "\"".concat(_this.npmPath, "\""); } if (_this.log.isEnabled()) { - _this.log.writeLine("Process id: " + process.pid); - _this.log.writeLine("NPM location: " + _this.npmPath + " (explicit '" + server.Arguments.NpmLocation + "' " + (npmLocation === undefined ? "not " : "") + " provided)"); - _this.log.writeLine("validateDefaultNpmLocation: " + validateDefaultNpmLocation); + _this.log.writeLine("Process id: ".concat(process.pid)); + _this.log.writeLine("NPM location: ".concat(_this.npmPath, " (explicit '").concat(server.Arguments.NpmLocation, "' ").concat(npmLocation === undefined ? "not " : "", " provided)")); + _this.log.writeLine("validateDefaultNpmLocation: ".concat(validateDefaultNpmLocation)); } (_this.nodeExecSync = require("child_process").execSync); _this.ensurePackageDirectoryExists(globalTypingsCacheLocation); try { if (_this.log.isEnabled()) { - _this.log.writeLine("Updating " + typesRegistryPackageName + " npm package..."); + _this.log.writeLine("Updating ".concat(typesRegistryPackageName, " npm package...")); } - _this.execSyncAndLog(_this.npmPath + " install --ignore-scripts " + typesRegistryPackageName + "@" + _this.latestDistTag, { cwd: globalTypingsCacheLocation }); + _this.execSyncAndLog("".concat(_this.npmPath, " install --ignore-scripts ").concat(typesRegistryPackageName, "@").concat(_this.latestDistTag), { cwd: globalTypingsCacheLocation }); if (_this.log.isEnabled()) { - _this.log.writeLine("Updated " + typesRegistryPackageName + " npm package"); + _this.log.writeLine("Updated ".concat(typesRegistryPackageName, " npm package")); } } catch (e) { if (_this.log.isEnabled()) { - _this.log.writeLine("Error updating " + typesRegistryPackageName + " package: " + e.message); + _this.log.writeLine("Error updating ".concat(typesRegistryPackageName, " package: ").concat(e.message)); } _this.delayedInitializationError = { kind: "event::initializationFailed", @@ -125912,7 +126332,7 @@ var ts; var cwd = getDirectoryOfPackageJson(fileName, _this.installTypingHost) || projectRootPath; if (cwd) { _this.installWorker(-1, [packageName_1], cwd, function (success) { - var message = success ? "Package " + packageName_1 + " installed." : "There was an error installing " + packageName_1 + "."; + var message = success ? "Package ".concat(packageName_1, " installed.") : "There was an error installing ".concat(packageName_1, "."); var response = { kind: server.ActionPackageInstalled, projectName: projectName_1, success: success, message: message }; _this.sendResponse(response); }); @@ -125930,7 +126350,7 @@ var ts; }; NodeTypingsInstaller.prototype.sendResponse = function (response) { if (this.log.isEnabled()) { - this.log.writeLine("Sending response:\n " + JSON.stringify(response)); + this.log.writeLine("Sending response:\n ".concat(JSON.stringify(response))); } process.send(response); if (this.log.isEnabled()) { @@ -125940,29 +126360,29 @@ var ts; NodeTypingsInstaller.prototype.installWorker = function (requestId, packageNames, cwd, onRequestCompleted) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("#" + requestId + " with arguments'" + JSON.stringify(packageNames) + "'."); + this.log.writeLine("#".concat(requestId, " with arguments'").concat(JSON.stringify(packageNames), "'.")); } var start = Date.now(); var hasError = typingsInstaller.installNpmPackages(this.npmPath, ts.version, packageNames, function (command) { return _this.execSyncAndLog(command, { cwd: cwd }); }); if (this.log.isEnabled()) { - this.log.writeLine("npm install #" + requestId + " took: " + (Date.now() - start) + " ms"); + this.log.writeLine("npm install #".concat(requestId, " took: ").concat(Date.now() - start, " ms")); } onRequestCompleted(!hasError); }; NodeTypingsInstaller.prototype.execSyncAndLog = function (command, options) { if (this.log.isEnabled()) { - this.log.writeLine("Exec: " + command); + this.log.writeLine("Exec: ".concat(command)); } try { var stdout = this.nodeExecSync(command, __assign(__assign({}, options), { encoding: "utf-8" })); if (this.log.isEnabled()) { - this.log.writeLine(" Succeeded. stdout:" + indent(ts.sys.newLine, stdout)); + this.log.writeLine(" Succeeded. stdout:".concat(indent(ts.sys.newLine, stdout))); } return false; } catch (error) { var stdout = error.stdout, stderr = error.stderr; - this.log.writeLine(" Failed. stdout:" + indent(ts.sys.newLine, stdout) + ts.sys.newLine + " stderr:" + indent(ts.sys.newLine, stderr)); + this.log.writeLine(" Failed. stdout:".concat(indent(ts.sys.newLine, stdout)).concat(ts.sys.newLine, " stderr:").concat(indent(ts.sys.newLine, stderr))); return true; } }; @@ -125985,7 +126405,7 @@ var ts; var log = new FileLog(logFilePath); if (log.isEnabled()) { process.on("uncaughtException", function (e) { - log.writeLine("Unhandled exception: " + e + " at " + e.stack); + log.writeLine("Unhandled exception: ".concat(e, " at ").concat(e.stack)); }); } process.on("disconnect", function () { @@ -125998,7 +126418,7 @@ var ts; installer.listen(); function indent(newline, str) { return str && str.length - ? newline + " " + str.replace(/\r?\n/, newline + " ") + ? "".concat(newline, " ") + str.replace(/\r?\n/, "".concat(newline, " ")) : ""; } })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index 809d6d1a1dc99..96d82ecd7cde2 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "将 \"void\" 添加到已解析但没有值的承诺", "Add_void_to_all_Promises_resolved_without_a_value_95144": "将 \"void\" 添加到所有已解析但没有值的承诺", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "添加 tsconfig.json 文件有助于组织包含 TypeScript 和 JavaScript 文件的项目。有关详细信息,请访问 https://aka.ms/tsconfig。", + "All_declarations_of_0_must_have_identical_constraints_2838": "\"{0}\" 的所有声明必须具有相同的限制。", "All_declarations_of_0_must_have_identical_modifiers_2687": "“{0}”的所有声明必须具有相同的修饰符。", "All_declarations_of_0_must_have_identical_type_parameters_2428": "“{0}”的所有声明都必须具有相同的类型参数。", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象方法的所有声明必须是连续的。", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "类型“{0}”的索引签名重复。", "Duplicate_label_0_1114": "标签“{0}”重复。", "Duplicate_property_0_2718": "重复的属性 \"{0}\"。", - "Dynamic_import_cannot_have_type_arguments_1326": "动态导入不能含有类型参数。", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "动态导入的说明符类型必须是 \"string\",但此处类型是 \"{0}\"。", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "仅当 '--module' 标志设置为 'es2020'、'es2022'、'esnext'、 'commonjs'、'amd'、'system'、'umd'、'node12' 或 'nodenext' 时,才支持动态导入。", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "动态导入只能接受模块说明符和可选断言作为参数", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "应为 {0} 个参数,但得到的却是 {1} 个。你是否忘了将类型参数中的 \"void\" 包含到 \"Promise\"?", "Expected_0_type_arguments_but_got_1_2558": "应有 {0} 个类型参数,但获得 {1} 个。", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "应为 {0} 类型参数;请为这些参数添加 \"@extends\" 标记。", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "应为 1 个参数,但得到 0。“new Promise()” 需要 JSDoc 提示才能生成可在没有参数的情况下调用的 “resolve”。", "Expected_at_least_0_arguments_but_got_1_2555": "应有至少 {0} 个参数,但获得 {1} 个。", "Expected_corresponding_JSX_closing_tag_for_0_17002": "“{0}”预期的相应 JSX 结束标记。", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "预期的 JSX 片段的相应结束标记。", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "此语法需要名为 \"{1}\" 的导入帮助器,\"{0}\" 中不存在该帮助器。请考虑升级 \"{0}\" 的版本。", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "此语法需要一个名为 \"{1}\" 且包含 {2} 参数的导入帮助程序,该帮助程序与 \"{0}\" 中的相应帮助程序不兼容。请考虑升级 \"{0}\" 的版本。", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "此类型参数可能需要 \"extends object\" 约束。", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "“import” 的这种用法无效。可以写入 “import()” 调用,但它们必须具有括号,并且不能带有类型参数。", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "仅当 'module' 选项设置为 'es2022'、'esnext'、'system' 或 'nodenext',且 'target' 选项设置为 'es2017' 或更高版本时,才允许顶级 'await' 表达式。", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 文件中的顶级声明必须以 \"declare\" 或 \"export\" 修饰符开头。", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "仅当 'module' 选项设置为 'es2022'、'esnext'、'system' 或 'nodenext',且 'target' 选项设置为 'es2017' 或更高版本时,才允许顶级 'for await' 循环。", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "类型“{0}”不是 ES5/ES3 中的有效异步函数返回类型,因为其未引用与 Promise 相符的构造函数值。", "Type_0_is_not_an_array_type_2461": "类型“{0}”不是数组类型。", "Type_0_is_not_an_array_type_or_a_string_type_2495": "类型“{0}”不是数组类型或字符串类型。", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "类型“{0}”不是数组类型或字符串类型。请使用编译器选项 \"--downlevelIteration\" 允许迭代器进行迭代。", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "类型“{0}”不是数组类型或字符串类型,或者没有返回迭代器的 \"[Symbol.iterator]()\" 方法。", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "类型“{0}”不是数组类型,或者没有返回迭代器的 \"[Symbol.iterator]()\" 方法。", "Type_0_is_not_assignable_to_type_1_2322": "不能将类型“{0}”分配给类型“{1}”。", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "变量声明列表不能为空。", "Variable_declaration_not_allowed_at_this_location_1440": "此位置不允许使用变量声明。", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "源中位置 {0} 的可变元素与目标中位置 {1} 的元素不匹配。", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "仅对象、函数、构造函数、映射类型的类型别名支持方差注释。", "Version_0_6029": "版本 {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "请访问 https://aka.ms/tsconfig,了解有关此文件的详细信息", "WATCH_OPTIONS_6918": "监视选项", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index b4288206e800c..c7748fd7604fc 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -161,6 +161,7 @@ "Add_void_to_Promise_resolved_without_a_value_95143": "為已經解析但不具值的 Promise 新增 'void'", "Add_void_to_all_Promises_resolved_without_a_value_95144": "為已經解析但不具值的所有 Promise 新增 'void'", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "新增 tsconfig.json 檔案有助於組織同時包含 TypeScript 及 JavaScript 檔案的專案。若要深入了解,請前往 https://aka.ms/tsconfig。", + "All_declarations_of_0_must_have_identical_constraints_2838": "'{0}' 的所有宣告都必須有相同的限制式。", "All_declarations_of_0_must_have_identical_modifiers_2687": "'{0}' 的所有宣告都必須有相同修飾元。", "All_declarations_of_0_must_have_identical_type_parameters_2428": "'{0}' 的所有宣告都必須具有相同的類型參數。", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象方法的所有宣告必須連續。", @@ -573,7 +574,6 @@ "Duplicate_index_signature_for_type_0_2374": "類型 '{0}' 的索引簽章重複。", "Duplicate_label_0_1114": "標籤 '{0}' 重複。", "Duplicate_property_0_2718": "屬性 '{0}' 重複。", - "Dynamic_import_cannot_have_type_arguments_1326": "動態匯入不可有型別引數。", "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "動態匯入的指定名稱必須屬於類型 'string',但這裡的類型為 '{0}'。", "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323": "只有在 '--module' 旗標設定為 'es2020'、'es2022'、'esnext'、'commonjs'、'amd'、'system'、'umd'、'node12' 或 'nodenext',才支援動態匯入。", "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450": "動態匯入只能接受模組指定名稱和選擇性判斷提示來做為引數", @@ -642,6 +642,7 @@ "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794": "應為 {0} 個引數,但現有 {1} 個。是否忘記將型別引數中的 'void' 納入 'Promise' 中?", "Expected_0_type_arguments_but_got_1_2558": "應有 {0} 個型別引數,但得到 {1} 個。", "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026": "必須是 {0} 型別引數; 請提供有 '@ extends' 標記的這類引數。", + "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810": "需要 1 個引數,但得到 0。'new Promise()' 需要 JSDoc 提示,才能產生可以呼叫而不含引數的 'resolve'。", "Expected_at_least_0_arguments_but_got_1_2555": "至少應有 {0} 個引數,但得到 {1} 個。", "Expected_corresponding_JSX_closing_tag_for_0_17002": "'{0}' 需要對應的 JSX 結尾標記。", "Expected_corresponding_closing_tag_for_JSX_fragment_17015": "JSX 片段必須有對應的結尾標記。", @@ -1483,6 +1484,7 @@ "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "此語法需要名為 '{1}' 的已匯入協助程式,但其不存在於 '{0}' 中。請考慮升級您的 '{0}' 版本。", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "此語法需要名為 '{1}' 且具有 {2} 參數的匯入協助程式,其與 '{0}' 中的參數不相容。請考慮升級 '{0}' 的版本。", "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "此類型參數可能需要 'extends object' 限制式。", + "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "此 'import' 的使用方式無效。'import()' 呼叫可以寫入,但必須有括弧,而且不能有類型引數。", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378": "只有在 'module' 選項設定為 'es2022'、'esnext'、'system' 或 'nodenext',而且 'target' 選項設定為 'es2017' 或更高版本時,才允許最上層的 'await' 運算式。", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 檔案中的最上層宣告必須以 'declare' 或 'export' 修飾元開頭。", "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432": "只有在 'module' 選項設為 'es2022'、'esnext'、'system' 或 'nodenext',而且 'target' 選項設為 'es2017' 或更高版本時,才允許最上層的 'for await' 迴圈。", @@ -1509,7 +1511,6 @@ "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "類型 '{0}' 不是 ES5/ES3 中的有效非同步函式傳回型別,因為它不是指與 Promise 相容的建構函式值。", "Type_0_is_not_an_array_type_2461": "類型 '{0}' 不是陣列類型。", "Type_0_is_not_an_array_type_or_a_string_type_2495": "類型 '{0}' 不是陣列類型或字串類型。", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569": "類型 '{0}' 不是陣列類型或字串類型。請使用編譯器選項 '-downlevelIteration' 允許逐一查看迭代器。", "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549": "類型 '{0}' 不是陣列類型或字串類型,或沒有會傳回迭代器的 '[Symbol.iterator]()' 方法。", "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548": "類型 '{0}' 不是陣列類型,或沒有會傳回迭代器的 '[Symbol.iterator]()' 方法。", "Type_0_is_not_assignable_to_type_1_2322": "類型 '{0}' 不可指派給類型 '{1}'。", @@ -1633,6 +1634,7 @@ "Variable_declaration_list_cannot_be_empty_1123": "變數宣告清單不得為空白。", "Variable_declaration_not_allowed_at_this_location_1440": "此位置不允許變數宣告。", "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625": "來源中位於 {0} 的可變元素與目標中位於 {1} 的元素不相符。", + "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637": "只有物件、函式、建構函式和對應類型的類型別名才支援差異註釋。", "Version_0_6029": "版本 {0}", "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110": "瀏覽 https://aka.ms/tsconfig 以閱讀此檔案的詳細資訊", "WATCH_OPTIONS_6918": "監看式選項", diff --git a/package-lock.json b/package-lock.json index e9fbb2e57001b..46831288f2dd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -392,9 +392,9 @@ } }, "@types/chai": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz", - "integrity": "sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", + "integrity": "sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==", "dev": true }, "@types/convert-source-map": { @@ -626,9 +626,9 @@ } }, "@types/mocha": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", - "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz", + "integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==", "dev": true }, "@types/ms": { @@ -638,9 +638,9 @@ "dev": true }, "@types/node": { - "version": "17.0.23", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz", - "integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==", + "version": "17.0.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz", + "integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q==", "dev": true }, "@types/node-fetch": { @@ -2987,6 +2987,22 @@ "dev": true, "requires": { "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } } } @@ -3135,17 +3151,37 @@ "dev": true }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.1.tgz", + "integrity": "sha512-cF7FYZZ47YzmCu7dDy50xSRRfO3ErRfrXuLZcNIuyiJEco0XSrGtuilG19L5xp3NcwTx7Gn+X6Tv3fmsUPTbow==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^5.0.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "glob-parent": { @@ -3185,6 +3221,22 @@ "remove-trailing-separator": "^1.0.1", "to-absolute-glob": "^2.0.0", "unique-stream": "^2.0.2" + }, + "dependencies": { + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "glob-watcher": { @@ -3249,6 +3301,22 @@ "ignore": "^5.1.1", "merge2": "^1.2.3", "slash": "^3.0.0" + }, + "dependencies": { + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "glogg": { @@ -3266,12 +3334,6 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, "gulp": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz", @@ -3382,6 +3444,22 @@ "glob": "^7.0.3", "kew": "^0.7.0", "plugin-error": "^0.1.2" + }, + "dependencies": { + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "gulp-rename": { @@ -4244,32 +4322,30 @@ "dev": true }, "mocha": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", - "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.0.0.tgz", + "integrity": "sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", "chokidar": "3.5.3", - "debug": "4.3.3", + "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", "glob": "7.2.0", - "growl": "1.10.5", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "4.2.1", + "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.1", + "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", + "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" @@ -4346,9 +4422,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -4412,6 +4488,31 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -4461,12 +4562,23 @@ } }, "minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + } } }, "p-limit": { @@ -4542,15 +4654,6 @@ "is-number": "^7.0.0" } }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -4617,9 +4720,9 @@ "optional": true }, "nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true }, "nanomatch": { @@ -5426,6 +5529,22 @@ "dev": true, "requires": { "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "run-parallel": { @@ -6560,9 +6679,9 @@ "dev": true }, "workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "wrap-ansi": { diff --git a/package.json b/package.json index 8580031ed04d8..6fd0e004159ce 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.7.0-beta", + "version": "4.7.1-rc", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 10c6db79cf1f3..84cd23bfc103c 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -122,7 +122,9 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, try { setNodeEnvToDevelopment(); - const { exitCode } = await exec("node", args, { cancelToken }); + const { exitCode } = await exec(process.execPath, args, { + cancelToken, + }); if (exitCode !== 0) { errorStatus = exitCode; error = new Error(`Process exited with status code ${errorStatus}.`); diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a5dc3db10bc3a..66a9f6393dc75 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1818,6 +1818,7 @@ namespace ts { case SyntaxKind.ModuleDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.MappedType: + case SyntaxKind.IndexSignature: return ContainerFlags.IsContainer | ContainerFlags.HasLocals; case SyntaxKind.SourceFile: @@ -1838,7 +1839,6 @@ namespace ts { case SyntaxKind.JSDocFunctionType: case SyntaxKind.FunctionType: case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: case SyntaxKind.ConstructorType: case SyntaxKind.ClassStaticBlockDeclaration: return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike; diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index aec8cae3cea12..0485f10cbf071 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -161,6 +161,8 @@ namespace ts { * true if program has been emitted */ programEmitComplete?: true; + /** Stores list of files that change signature during emit - test only */ + filesChangingSignature?: Set; } function hasSameKeys(map1: ReadonlyCollection | undefined, map2: ReadonlyCollection | undefined): boolean { @@ -348,7 +350,7 @@ namespace ts { * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state: BuilderProgramState, cancellationToken: CancellationToken | undefined, computeHash: BuilderState.ComputeHash): SourceFile | Program | undefined { + function getNextAffectedFile(state: BuilderProgramState, cancellationToken: CancellationToken | undefined, computeHash: BuilderState.ComputeHash, host: BuilderProgramHost): SourceFile | Program | undefined { while (true) { const { affectedFiles } = state; if (affectedFiles) { @@ -359,7 +361,7 @@ namespace ts { if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); return affectedFile; } affectedFilesIndex++; @@ -372,6 +374,7 @@ namespace ts { BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures!); state.currentAffectedFilesSignatures!.clear(); BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + state.currentAffectedFilesExportedModulesMap?.clear(); state.affectedFiles = undefined; } @@ -403,6 +406,12 @@ namespace ts { } } + function clearAffectedFilesPendingEmit(state: BuilderProgramState) { + state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; + state.affectedFilesPendingEmitIndex = undefined; + } + /** * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet */ @@ -422,32 +431,40 @@ namespace ts { } } } - state.affectedFilesPendingEmit = undefined; - state.affectedFilesPendingEmitKind = undefined; - state.affectedFilesPendingEmitIndex = undefined; + clearAffectedFilesPendingEmit(state); } return undefined; } + function removeDiagnosticsOfLibraryFiles(state: BuilderProgramState) { + if (!state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + const program = Debug.checkDefined(state.program); + const options = program.getCompilerOptions(); + forEach(program.getSourceFiles(), f => + program.isSourceFileDefaultLibrary(f) && + !skipTypeChecking(f, options, program) && + removeSemanticDiagnosticsOf(state, f.resolvedPath) + ); + } + } + /** * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state: BuilderProgramState, affectedFile: SourceFile, cancellationToken: CancellationToken | undefined, computeHash: BuilderState.ComputeHash) { + function handleDtsMayChangeOfAffectedFile( + state: BuilderProgramState, + affectedFile: SourceFile, + cancellationToken: CancellationToken | undefined, + computeHash: BuilderState.ComputeHash, + host: BuilderProgramHost, + ) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { - if (!state.cleanedDiagnosticsOfLibFiles) { - state.cleanedDiagnosticsOfLibFiles = true; - const program = Debug.checkDefined(state.program); - const options = program.getCompilerOptions(); - forEach(program.getSourceFiles(), f => - program.isSourceFileDefaultLibrary(f) && - !skipTypeChecking(f, options, program) && - removeSemanticDiagnosticsOf(state, f.resolvedPath) - ); - } + removeDiagnosticsOfLibraryFiles(state); // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. @@ -462,20 +479,22 @@ namespace ts { ); return; } - else { - Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || state.currentAffectedFilesSignatures?.has(affectedFile.resolvedPath), `Signature not updated for affected file: ${affectedFile.fileName}`); - } - - if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { - forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, (state, path) => handleDtsMayChangeOf(state, path, cancellationToken, computeHash)); - } + Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || state.currentAffectedFilesSignatures?.has(affectedFile.resolvedPath), `Signature not updated for affected file: ${affectedFile.fileName}`); + if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state: BuilderProgramState, path: Path, cancellationToken: CancellationToken | undefined, computeHash: BuilderState.ComputeHash): void { + function handleDtsMayChangeOf( + state: BuilderProgramState, + path: Path, + cancellationToken: CancellationToken | undefined, + computeHash: BuilderState.ComputeHash, + host: BuilderProgramHost + ): void { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { @@ -495,7 +514,7 @@ namespace ts { cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, - /* useFileVersionAsSignature */ true + !host.disableUseFileVersionAsSignature ); // If not dts emit, nothing more to do if (getEmitDeclarations(state.compilerOptions)) { @@ -524,16 +543,61 @@ namespace ts { return newSignature !== oldSignature; } + function forEachKeyOfExportedModulesMap( + state: BuilderProgramState, + filePath: Path, + fn: (exportedFromPath: Path) => T | undefined, + ): T | undefined { + // Go through exported modules from cache first + let keys = state.currentAffectedFilesExportedModulesMap!.getKeys(filePath); + const result = keys && forEachKey(keys, fn); + if (result) return result; + + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + keys = state.exportedModulesMap!.getKeys(filePath); + return keys && forEachKey(keys, exportedFromPath => + // If the cache had an updated value, skip + !state.currentAffectedFilesExportedModulesMap!.hasKey(exportedFromPath) && + !state.currentAffectedFilesExportedModulesMap!.deletedKeys()?.has(exportedFromPath) ? + fn(exportedFromPath) : + undefined + ); + } + + function handleDtsMayChangeOfGlobalScope( + state: BuilderProgramState, + filePath: Path, + cancellationToken: CancellationToken | undefined, + computeHash: BuilderState.ComputeHash, + host: BuilderProgramHost, + ): boolean { + if (!state.fileInfos.get(filePath)?.affectsGlobalScope) return false; + // Every file needs to be handled + BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program!, /*firstSourceFile*/ undefined) + .forEach(file => handleDtsMayChangeOf( + state, + file.resolvedPath, + cancellationToken, + computeHash, + host, + )); + removeDiagnosticsOfLibraryFiles(state); + return true; + } + /** - * Iterate on referencing modules that export entities from affected file + * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function forEachReferencingModulesOfExportOfAffectedFile(state: BuilderProgramState, affectedFile: SourceFile, fn: (state: BuilderProgramState, filePath: Path) => void) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile( + state: BuilderProgramState, + affectedFile: SourceFile, + cancellationToken: CancellationToken | undefined, + computeHash: BuilderState.ComputeHash, + host: BuilderProgramHost + ) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { - return; - } - + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself @@ -546,7 +610,8 @@ namespace ts { const currentPath = queue.pop()!; if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - fn(state, currentPath); + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) return; + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); if (isChangedSignature(state, currentPath)) { const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath)!; queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -556,65 +621,69 @@ namespace ts { } Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - const seenFileAndExportsOfFile = new Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)?.forEach(exportedFromPath => - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn) - ); - - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - state.exportedModulesMap.getKeys(affectedFile.resolvedPath)?.forEach(exportedFromPath => - // If the cache had an updated value, skip - !state.currentAffectedFilesExportedModulesMap!.hasKey(exportedFromPath) && - !state.currentAffectedFilesExportedModulesMap!.deletedKeys()?.has(exportedFromPath) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn) - ); - } - - /** - * Iterate on files referencing referencedPath - */ - function forEachFilesReferencingPath(state: BuilderProgramState, referencedPath: Path, seenFileAndExportsOfFile: Set, fn: (state: BuilderProgramState, filePath: Path) => void): void { - state.referencedMap!.getKeys(referencedPath)?.forEach(filePath => - forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) - ); + forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, exportedFromPath => { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) return true; + const references = state.referencedMap!.getKeys(exportedFromPath); + return references && forEachKey(references, filePath => + handleDtsMayChangeOfFileAndExportsOfFile( + state, + filePath, + seenFileAndExportsOfFile, + cancellationToken, + computeHash, + host, + ) + ); + }); } /** - * fn on file and iterate on anything that exports this file + * handle dts and semantic diagnostics on file and iterate on anything that exports this file + * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function forEachFileAndExportsOfFile(state: BuilderProgramState, filePath: Path, seenFileAndExportsOfFile: Set, fn: (state: BuilderProgramState, filePath: Path) => void): void { - if (!tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return; - } - - fn(state, filePath); - + function handleDtsMayChangeOfFileAndExportsOfFile( + state: BuilderProgramState, + filePath: Path, + seenFileAndExportsOfFile: Set, + cancellationToken: CancellationToken | undefined, + computeHash: BuilderState.ComputeHash, + host: BuilderProgramHost, + ): boolean | undefined { + if (!tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; + + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) return true; + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - // Go through exported modules from cache first - // If exported modules has path, all files referencing file exported from are affected - state.currentAffectedFilesExportedModulesMap.getKeys(filePath)?.forEach(exportedFromPath => - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn) - ); - // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - state.exportedModulesMap!.getKeys(filePath)?.forEach(exportedFromPath => - // If the cache had an updated value, skip - !state.currentAffectedFilesExportedModulesMap!.hasKey(exportedFromPath) && - !state.currentAffectedFilesExportedModulesMap!.deletedKeys()?.has(exportedFromPath) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn) + // If exported modules has path, all files referencing file exported from are affected + forEachKeyOfExportedModulesMap(state, filePath, exportedFromPath => + handleDtsMayChangeOfFileAndExportsOfFile( + state, + exportedFromPath, + seenFileAndExportsOfFile, + cancellationToken, + computeHash, + host, + ) ); // Remove diagnostics of files that import this file (without going to exports of referencing files) state.referencedMap!.getKeys(filePath)?.forEach(referencingFilePath => !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file - fn(state, referencingFilePath) // Dont add to seen since this is not yet done with the export removal + handleDtsMayChangeOf( // Dont add to seen since this is not yet done with the export removal + state, + referencingFilePath, + cancellationToken, + computeHash, + host, + ) ); + return undefined; } - /** * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly @@ -751,13 +820,18 @@ namespace ts { const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); const actualSignature = signature ?? value.signature; return value.version === actualSignature ? - value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : + value.affectsGlobalScope || value.impliedFormat ? + // If file version is same as signature, dont serialize signature + { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // If file info only contains version and signature and both are same we can just write string value.version : - actualSignature !== undefined ? + actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo signature === undefined ? + // If we havent computed signature, use fileInfo as is value : + // Serialize fileInfo with new updated signature { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + // Signature of the FileInfo is undefined, serialize it as false { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); @@ -1039,7 +1113,7 @@ namespace ts { * in that order would be used to write the files */ function emitNextAffectedFile(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): AffectedFileResult { - let affected = getNextAffectedFile(state, cancellationToken, computeHash); + let affected = getNextAffectedFile(state, cancellationToken, computeHash, host); let emitKind = BuilderFileEmit.Full; let isPendingEmitFile = false; if (!affected) { @@ -1078,7 +1152,9 @@ namespace ts { // Otherwise just affected file Debug.checkDefined(state.program).emit( affected === state.program ? undefined : affected as SourceFile, - writeFile || maybeBind(host, host.writeFile), + affected !== state.program && getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === BuilderFileEmit.DtsOnly, customTransformers @@ -1089,6 +1165,34 @@ namespace ts { ); } + function getWriteFileUpdatingSignatureCallback(writeFile: WriteFileCallback | undefined): WriteFileCallback { + return (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => { + if (isDeclarationFileName(fileName)) { + Debug.assert(sourceFiles?.length === 1); + const file = sourceFiles[0]; + const info = state.fileInfos.get(file.resolvedPath)!; + const signature = state.currentAffectedFilesSignatures?.get(file.resolvedPath) || info.signature; + if (signature === file.version) { + const newSignature = (computeHash || generateDjb2Hash)(data?.sourceMapUrlPos !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); + if (newSignature !== file.version) { // Update it + if (host.storeFilesChangingSignatureDuringEmit) (state.filesChangingSignature ||= new Set()).add(file.resolvedPath); + if (state.exportedModulesMap) BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap ||= BuilderState.createManyToManyPathMap()); + if (state.affectedFiles && state.affectedFilesIndex! < state.affectedFiles.length) { + state.currentAffectedFilesSignatures!.set(file.resolvedPath, newSignature); + } + else { + info.signature = newSignature; + if (state.exportedModulesMap) BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + } + } + } + } + if (writeFile) writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else if (host.writeFile) host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + else state.program!.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + }; + } + /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -1101,59 +1205,57 @@ namespace ts { * in that order would be used to write the files */ function emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult { - let restorePendingEmitOnHandlingNoEmitSuccess = false; - let savedAffectedFilesPendingEmit; - let savedAffectedFilesPendingEmitKind; - let savedAffectedFilesPendingEmitIndex; - // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors - // This ensures pending files to emit is updated in tsbuildinfo - // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit) - if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram && - !targetSourceFile && - !outFile(state.compilerOptions) && - !state.compilerOptions.noEmit && - state.compilerOptions.noEmitOnError) { - restorePendingEmitOnHandlingNoEmitSuccess = true; - savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new Map(state.affectedFilesPendingEmitKind); - savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - } - if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); } const result = handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken); if (result) return result; - if (restorePendingEmitOnHandlingNoEmitSuccess) { - state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit; - state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind; - state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex; - } - // Emit only affected files if using builder for emit - if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - // Emit and report any errors we ran into. - let sourceMaps: SourceMapEmitResult[] = []; - let emitSkipped = false; - let diagnostics: Diagnostic[] | undefined; - let emittedFiles: string[] = []; - - let affectedEmitResult: AffectedFileResult; - while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { - emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; - diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics); - emittedFiles = addRange(emittedFiles, affectedEmitResult.result.emittedFiles); - sourceMaps = addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + if (!targetSourceFile) { + if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { + // Emit and report any errors we ran into. + let sourceMaps: SourceMapEmitResult[] = []; + let emitSkipped = false; + let diagnostics: Diagnostic[] | undefined; + let emittedFiles: string[] = []; + + let affectedEmitResult: AffectedFileResult; + while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) { + emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped; + diagnostics = addRange(diagnostics, affectedEmitResult.result.diagnostics); + emittedFiles = addRange(emittedFiles, affectedEmitResult.result.emittedFiles); + sourceMaps = addRange(sourceMaps, affectedEmitResult.result.sourceMaps); + } + return { + emitSkipped, + diagnostics: diagnostics || emptyArray, + emittedFiles, + sourceMaps + }; + } + // In non Emit builder, clear affected files pending emit + else if (state.affectedFilesPendingEmitKind?.size) { + Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram); + // State can clear affected files pending emit if + if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared + // If every file pending emit is pending on only dts emit + || every(state.affectedFilesPendingEmit, (path, index) => + index < state.affectedFilesPendingEmitIndex! || + state.affectedFilesPendingEmitKind!.get(path) === BuilderFileEmit.DtsOnly)) { + clearAffectedFilesPendingEmit(state); + } } - return { - emitSkipped, - diagnostics: diagnostics || emptyArray, - emittedFiles, - sourceMaps - }; } - return Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return Debug.checkDefined(state.program).emit( + targetSourceFile, + !outFile(state.compilerOptions) && getEmitDeclarations(state.compilerOptions) && !customTransformers ? + getWriteFileUpdatingSignatureCallback(writeFile) : + writeFile || maybeBind(host, host.writeFile), + cancellationToken, + emitOnlyDtsFiles, + customTransformers + ); } /** @@ -1162,7 +1264,7 @@ namespace ts { */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult { while (true) { - const affected = getNextAffectedFile(state, cancellationToken, computeHash); + const affected = getNextAffectedFile(state, cancellationToken, computeHash, host); if (!affected) { // Done return undefined; diff --git a/src/compiler/builderPublic.ts b/src/compiler/builderPublic.ts index 5d5d2ed25dd52..a3527a83f9fa2 100644 --- a/src/compiler/builderPublic.ts +++ b/src/compiler/builderPublic.ts @@ -20,6 +20,11 @@ namespace ts { */ /*@internal*/ disableUseFileVersionAsSignature?: boolean; + /** + * Store the list of files that update signature during the emit + */ + /*@internal*/ + storeFilesChangingSignatureDuringEmit?: boolean; } /** diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index a64a6c13ed1e8..f501eda66a1d1 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -48,11 +48,6 @@ namespace ts { */ readonly exportedModulesMap: BuilderState.ManyToManyPathMap | undefined; - previousCache?: { - id: number, - version: number, - }; - /** * true if file version is used as signature * This helps in delaying the calculation of the d.ts hash as version for the file till reasonable time @@ -81,12 +76,11 @@ namespace ts { export interface FileInfo { readonly version: string; signature: string | undefined; - affectsGlobalScope: boolean | undefined; + affectsGlobalScope: true | undefined; impliedFormat: number | undefined; } export interface ReadonlyManyToManyPathMap { - readonly id: number; clone(): ManyToManyPathMap; forEach(action: (v: ReadonlySet, k: Path) => void): void; getKeys(v: Path): ReadonlySet | undefined; @@ -103,18 +97,14 @@ namespace ts { } export interface ManyToManyPathMap extends ReadonlyManyToManyPathMap { - version(): number; // Incremented each time the contents are changed deleteKey(k: Path): boolean; set(k: Path, v: ReadonlySet): void; + clear(): void; } - let manyToManyPathMapCount = 0; export function createManyToManyPathMap(): ManyToManyPathMap { function create(forward: ESMap>, reverse: ESMap>, deleted: Set | undefined): ManyToManyPathMap { - let version = 0; const map: ManyToManyPathMap = { - id: manyToManyPathMapCount++, - version: () => version, clone: () => create(new Map(forward), new Map(reverse), deleted && new Set(deleted)), forEach: fn => forward.forEach(fn), getKeys: v => reverse.get(v), @@ -133,35 +123,33 @@ namespace ts { set.forEach(v => deleteFromMultimap(reverse, v, k)); forward.delete(k); - version++; return true; }, set: (k, vSet) => { - let changed = !!deleted?.delete(k); + deleted?.delete(k); const existingVSet = forward.get(k); forward.set(k, vSet); existingVSet?.forEach(v => { if (!vSet.has(v)) { - changed = true; deleteFromMultimap(reverse, v, k); } }); vSet.forEach(v => { if (!existingVSet?.has(v)) { - changed = true; addToMultimap(reverse, v, k); } }); - if (changed) { - version++; - } - return map; }, + clear: () => { + forward.clear(); + reverse.clear(); + deleted?.clear(); + } }; return map; @@ -179,11 +167,11 @@ namespace ts { set.add(v); } - function deleteFromMultimap(map: ESMap>, k: K, v: V, removeEmpty = true): boolean { + function deleteFromMultimap(map: ESMap>, k: K, v: V): boolean { const set = map.get(k); if (set?.delete(v)) { - if (removeEmpty && !set.size) { + if (!set.size) { map.delete(k); } return true; @@ -434,7 +422,7 @@ namespace ts { ); const firstDts = firstOrUndefined(emitOutput.outputFiles); if (firstDts) { - Debug.assert(fileExtensionIsOneOf(firstDts.name, [Extension.Dts, Extension.Dmts, Extension.Dcts]), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`); + Debug.assert(isDeclarationFileName(firstDts.name), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`); latestSignature = (computeHash || generateDjb2Hash)(firstDts.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -462,7 +450,7 @@ namespace ts { /** * Coverts the declaration emit result into exported modules map */ - function updateExportedModules(sourceFile: SourceFile, exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined, exportedModulesMapCache: ManyToManyPathMap) { + export function updateExportedModules(sourceFile: SourceFile, exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined, exportedModulesMapCache: ManyToManyPathMap) { if (!exportedModulesFromDeclarationEmit) { exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); return; @@ -494,22 +482,6 @@ namespace ts { export function updateExportedFilesMapFromCache(state: BuilderState, exportedModulesMapCache: ManyToManyPathMap | undefined) { if (exportedModulesMapCache) { Debug.assert(!!state.exportedModulesMap); - - const cacheId = exportedModulesMapCache.id; - const cacheVersion = exportedModulesMapCache.version(); - if (state.previousCache) { - if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { - // If this is the same cache at the same version as last time this BuilderState - // was updated, there's no need to update again - return; - } - state.previousCache.id = cacheId; - state.previousCache.version = cacheVersion; - } - else { - state.previousCache = { id: cacheId, version: cacheVersion }; - } - exportedModulesMapCache.deletedKeys()?.forEach(path => state.exportedModulesMap!.deleteKey(path)); exportedModulesMapCache.forEach((exportedModules, path) => state.exportedModulesMap!.set(path, exportedModules)); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4fb6b55412e02..6370dddf49f52 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -833,6 +833,7 @@ namespace ts { const keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; const numberOrBigIntType = getUnionType([numberType, bigintType]); const templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]) as UnionType; + const numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type const restrictiveMapper: TypeMapper = makeFunctionTypeMapper(t => t.flags & TypeFlags.TypeParameter ? getRestrictiveTypeParameter(t as TypeParameter) : t); const permissiveMapper: TypeMapper = makeFunctionTypeMapper(t => t.flags & TypeFlags.TypeParameter ? wildcardType : t); @@ -1047,7 +1048,7 @@ namespace ts { const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -3116,27 +3117,27 @@ namespace ts { function resolveAlias(symbol: Symbol): Symbol { Debug.assert((symbol.flags & SymbolFlags.Alias) !== 0, "Should only get Alias here."); const links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; + if (!links.aliasTarget) { + links.aliasTarget = resolvingSymbol; const node = getDeclarationOfAliasSymbol(symbol); if (!node) return Debug.fail(); const target = getTargetOfAliasDeclaration(node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; + if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = target || unknownSymbol; } else { error(node, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); } } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; + else if (links.aliasTarget === resolvingSymbol) { + links.aliasTarget = unknownSymbol; } - return links.target; + return links.aliasTarget; } function tryResolveAlias(symbol: Symbol): Symbol | undefined { const links = getSymbolLinks(symbol); - if (links.target !== resolvingSymbol) { + if (links.aliasTarget !== resolvingSymbol) { return resolveAlias(symbol); } @@ -3527,7 +3528,7 @@ namespace ts { if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { const isSyncImport = (currentSourceFile.impliedNodeFormat === ModuleKind.CommonJS && !findAncestor(location, isImportCall)) || !!findAncestor(location, isImportEqualsDeclaration); const overrideClauseHost = findAncestor(location, l => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l)) as ImportTypeNode | ImportDeclaration | ExportDeclaration | undefined; const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? overrideClauseHost.assertions?.assertClause : overrideClauseHost?.assertClause; @@ -3536,9 +3537,6 @@ namespace ts { if (isSyncImport && sourceFile.impliedNodeFormat === ModuleKind.ESNext && !getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === Extension.Json) { - error(errorNode, Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -3595,7 +3593,7 @@ namespace ts { const tsExtension = tryExtractTSExtension(moduleReference); const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference); const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); - const resolutionIsNode12OrNext = moduleResolutionKind === ModuleResolutionKind.Node12 || + const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext; if (tsExtension) { const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -3616,16 +3614,16 @@ namespace ts { hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path)); const suggestedExt = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))?.[1]; if (suggestedExt) { error(errorNode, - Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, + Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -4109,7 +4107,7 @@ namespace ts { function getExportSymbolOfValueSymbolIfExported(symbol: Symbol): Symbol; function getExportSymbolOfValueSymbolIfExported(symbol: Symbol | undefined): Symbol | undefined; function getExportSymbolOfValueSymbolIfExported(symbol: Symbol | undefined): Symbol | undefined { - return getMergedSymbol(symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol: Symbol): boolean { @@ -5102,13 +5100,49 @@ namespace ts { function conditionalTypeToTypeNode(type: ConditionalType) { const checkTypeNode = typeToTypeNodeHelper(type.checkType, context); + context.approximateLength += 15; + if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && type.root.isDistributive && !(type.checkType.flags & TypeFlags.TypeParameter)) { + const newParam = createTypeParameter(createSymbol(SymbolFlags.TypeParameter, "T" as __String)); + const name = typeParameterToName(newParam, context); + const newTypeVariable = factory.createTypeReferenceNode(name); + context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type + const newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + const saveInferTypeParameters = context.inferTypeParameters; + context.inferTypeParameters = type.root.inferTypeParameters; + const extendsTypeNode = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); + context.inferTypeParameters = saveInferTypeParameters; + const trueTypeNode = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper)); + const falseTypeNode = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper)); + + + // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive + // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType + // inner conditional runs the check the user provided on the check type (distributively) and returns the result + // checkType extends infer T ? T extends checkType ? T extends extendsType ? trueType : falseType : never : never; + // this is potentially simplifiable to + // checkType extends infer T ? T extends checkType & extendsType ? trueType : falseType : never; + // but that may confuse users who read the output more. + // On the other hand, + // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; + // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. + return factory.createConditionalTypeNode( + checkTypeNode, + factory.createInferTypeNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, factory.cloneNode(newTypeVariable.typeName) as Identifier)), + factory.createConditionalTypeNode( + factory.createTypeReferenceNode(factory.cloneNode(name)), + typeToTypeNodeHelper(type.checkType, context), + factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode, trueTypeNode, falseTypeNode), + factory.createKeywordTypeNode(SyntaxKind.NeverKeyword) + ), + factory.createKeywordTypeNode(SyntaxKind.NeverKeyword) + ); + } const saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; const extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context); context.inferTypeParameters = saveInferTypeParameters; const trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type)); const falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type)); - context.approximateLength += 15; return factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } @@ -5879,9 +5913,6 @@ namespace ts { if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - if ((context.flags & NodeBuilderFlags.NoUndefinedOptionalParameterType) && parameterDeclaration && !isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) { - parameterType = getTypeWithFacts(parameterType, TypeFacts.NEUndefined); - } const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); const modifiers = !(context.flags & NodeBuilderFlags.OmitParameterModifiers) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(factory.cloneNode) : undefined; @@ -6157,7 +6188,7 @@ namespace ts { const targetFile = getSourceFileOfModule(chain[0]); let specifier: string | undefined; let assertion: ImportTypeAssertionContainer | undefined; - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if (targetFile?.impliedNodeFormat === ModuleKind.ESNext && targetFile.impliedNodeFormat !== contextFile?.impliedNodeFormat) { specifier = getSpecifierForModuleSymbol(chain[0], context, ModuleKind.ESNext); @@ -6174,7 +6205,7 @@ namespace ts { } if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { const oldSpecifier = specifier; - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set const swappedMode = contextFile?.impliedNodeFormat === ModuleKind.ESNext ? ModuleKind.CommonJS : ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -6508,7 +6539,7 @@ namespace ts { if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation)!; - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { const result = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result) { return result; @@ -6526,6 +6557,17 @@ namespace ts { return result; } + function typeNodeIsEquivalentToType(typeNode: TypeNode, annotatedDeclaration: Declaration, type: Type) { + const typeFromTypeNode = getTypeFromTypeNode(typeNode); + if (typeFromTypeNode === type) { + return true; + } + if (isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { + return getTypeWithFacts(type, TypeFacts.NEUndefined) === typeFromTypeNode; + } + return false; + } + function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) { if (!isErrorType(type) && context.enclosingDeclaration) { const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration); @@ -9162,7 +9204,7 @@ namespace ts { } } const sourceTypes = some(constructorTypes, t => !!(t.flags & ~TypeFlags.Nullable)) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes!, UnionReduction.Subtype); + type = getUnionType(sourceTypes!); } } const widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); @@ -11462,7 +11504,7 @@ namespace ts { if (symbol === globalThisSymbol) { const varsOnly = new Map() as SymbolTable; members.forEach(p => { - if (!(p.flags & SymbolFlags.BlockScoped)) { + if (!(p.flags & SymbolFlags.BlockScoped) && !(p.flags & SymbolFlags.ValueModule && p.declarations?.length && every(p.declarations, isAmbientModule))) { varsOnly.set(p.escapedName, p); } }); @@ -12063,7 +12105,7 @@ namespace ts { if (type.resolvedBaseConstraint) { return type.resolvedBaseConstraint; } - const stack: Type[] = []; + const stack: object[] = []; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t: Type): Type { @@ -12078,8 +12120,9 @@ namespace ts { // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of // nesting, so it is effectively just a safety stop. - if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) { - stack.push(t); + const identity = getRecursionIdentity(t); + if (stack.length < 10 || stack.length < 50 && !contains(stack, identity)) { + stack.push(identity); result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); stack.pop(); } @@ -12228,7 +12271,7 @@ namespace ts { const typeVariable = getHomomorphicTypeVariable(type); if (typeVariable && !type.declaration.nameType) { const constraint = getConstraintOfTypeParameter(typeVariable); - if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { + if (constraint && isArrayOrTupleType(constraint)) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } @@ -12609,10 +12652,10 @@ namespace ts { function isApplicableIndexType(source: Type, target: Type): boolean { // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index - // signature applies to types assignable to 'number' and numeric string literal types. + // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && !!(source.flags & TypeFlags.StringLiteral) && isNumericLiteralName((source as StringLiteralType).value); + target === numberType && (source === numericStringType || !!(source.flags & TypeFlags.StringLiteral) && isNumericLiteralName((source as StringLiteralType).value)); } function getIndexInfosOfStructuredType(type: Type): readonly IndexInfo[] { @@ -13733,6 +13776,20 @@ namespace ts { constraints = append(constraints, constraint); } } + // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the + // template type XXX, K has an added constraint of number | `${number}`. + else if (type.flags & TypeFlags.TypeParameter && parent.kind === SyntaxKind.MappedType && node === (parent as MappedTypeNode).type) { + const mappedType = getTypeFromTypeNode(parent as TypeNode) as MappedType; + if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { + const typeParameter = getHomomorphicTypeVariable(mappedType); + if (typeParameter) { + const constraint = getConstraintOfTypeParameter(typeParameter); + if (constraint && everyType(constraint, isArrayOrTupleType)) { + constraints = append(constraints, getUnionType([numberType, numericStringType])); + } + } + } + } node = parent; } return constraints ? getSubstitutionType(type, getIntersectionType(append(constraints, type))) : type; @@ -14772,7 +14829,7 @@ namespace ts { i--; const t = types[i]; const remove = - t.flags & TypeFlags.String && includes & TypeFlags.StringLiteral || + t.flags & TypeFlags.String && includes & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) || t.flags & TypeFlags.Number && includes & TypeFlags.NumberLiteral || t.flags & TypeFlags.BigInt && includes & TypeFlags.BigIntLiteral || t.flags & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol; @@ -14933,7 +14990,7 @@ namespace ts { if (!strictNullChecks && includes & TypeFlags.Nullable) { return includes & TypeFlags.Undefined ? undefinedType : nullType; } - if (includes & TypeFlags.String && includes & TypeFlags.StringLiteral || + if (includes & TypeFlags.String && includes & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) || includes & TypeFlags.Number && includes & TypeFlags.NumberLiteral || includes & TypeFlags.BigInt && includes & TypeFlags.BigIntLiteral || includes & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol) { @@ -15692,11 +15749,14 @@ namespace ts { return type[cache] = elementType; } } - // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper - // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we - // construct the type Box. - if (isGenericMappedType(objectType) && !objectType.declaration.nameType) { - return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), t => getSimplifiedType(t, writing)); + // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where + // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P. + // For example, for an index access { [P in K]: Box }[X], we construct the type Box. + if (isGenericMappedType(objectType)) { + const nameType = getNameTypeFromMappedType(objectType); + if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), t => getSimplifiedType(t, writing)); + } } return type[cache] = type; } @@ -16948,7 +17008,7 @@ namespace ts { if (!type.declaration.nameType) { let constraint; if (isArrayType(t) || t.flags & TypeFlags.Any && findResolutionCycleStartIndex(typeVariable, TypeSystemPropertyName.ImmediateBaseConstraint) < 0 && - (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, or(isArrayType, isTupleType))) { + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -18517,7 +18577,7 @@ namespace ts { } return false; } - return isTupleType(target) || isArrayType(target); + return isArrayOrTupleType(target); } if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { if (reportErrors) { @@ -18652,7 +18712,7 @@ namespace ts { // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && ( target.flags & TypeFlags.Intersection && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & TypeFlags.Intersection && getApparentType(source).flags & TypeFlags.StructuredType && !some((source as IntersectionType).types, t => !!(getObjectFlags(t) & ObjectFlags.NonInferrableType)))) { + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & TypeFlags.Intersection && getApparentType(source).flags & TypeFlags.StructuredType && !some((source as IntersectionType).types, t => !!(getObjectFlags(t) & ObjectFlags.NonInferrableType)))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, IntersectionState.PropertyCheck, recursionFlags); inPropertyCheck = false; @@ -18709,9 +18769,6 @@ namespace ts { return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & TypeFlags.TypeVariable && source.symbol?.declarations?.[0] && !getConstraintOfType(source as TypeVariable) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive))) { - associateRelatedInfo(createDiagnosticForNode(source.symbol.declarations[0], Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source: Type, target: Type): void { @@ -19502,7 +19559,7 @@ namespace ts { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch if (!(sourceFlags & TypeFlags.IndexedAccess && targetFlags & TypeFlags.IndexedAccess)) { const constraint = getConstraintOfType(source as TypeVariable); - if (!strictNullChecks && (!constraint || (sourceFlags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any))) { + if (!constraint || (sourceFlags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive), RecursionFlags.Both)) { resetErrorInfo(saveErrorInfo); @@ -19510,12 +19567,12 @@ namespace ts { } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, RecursionFlags.Source, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, RecursionFlags.Source, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, RecursionFlags.Source, reportErrors && !(targetFlags & sourceFlags & TypeFlags.TypeParameter), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, RecursionFlags.Source, reportErrors && !(targetFlags & sourceFlags & TypeFlags.TypeParameter), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -19660,7 +19717,7 @@ namespace ts { return varianceResult; } } - else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { + else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, RecursionFlags.Both, reportErrors); } @@ -20045,7 +20102,7 @@ namespace ts { } let result = Ternary.True; if (isTupleType(target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { return Ternary.False; } @@ -21050,6 +21107,10 @@ namespace ts { return !!(getObjectFlags(type) & ObjectFlags.Reference) && (type as TypeReference).target === globalReadonlyArrayType; } + function isArrayOrTupleType(type: Type): type is TypeReference { + return isArrayType(type) || isTupleType(type); + } + function isMutableArrayOrTuple(type: Type): boolean { return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly; } @@ -21550,7 +21611,7 @@ namespace ts { else if (type.flags & TypeFlags.Intersection) { result = getIntersectionType(sameMap((type as IntersectionType).types, getWidenedType)); } - else if (isArrayType(type) || isTupleType(type)) { + else if (isArrayOrTupleType(type)) { result = createTypeReference(type.target, sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { @@ -21587,7 +21648,7 @@ namespace ts { } } } - if (isArrayType(type) || isTupleType(type)) { + if (isArrayOrTupleType(type)) { for (const t of getTypeArguments(type)) { if (reportWideningErrorsInType(t)) { errorReported = true; @@ -22666,7 +22727,7 @@ namespace ts { } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { - if (isArrayType(source) || isTupleType(source)) { + if (isArrayOrTupleType(source)) { if (isTupleType(target)) { const sourceArity = getTypeReferenceArity(source); const targetArity = getTypeReferenceArity(target); @@ -25464,7 +25525,7 @@ namespace ts { if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { const parent = declaration.parent.parent; if (parent.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlags(declaration) & NodeFlags.Const || parent.kind === SyntaxKind.Parameter) { - const links = getNodeLinks(location); + const links = getNodeLinks(parent); if (!(links.flags & NodeCheckFlags.InCheckIdentifier)) { links.flags |= NodeCheckFlags.InCheckIdentifier; const parentType = getTypeForBindingElementParent(parent, CheckMode.Normal); @@ -27938,6 +27999,7 @@ namespace ts { } } else { + error(attributeDecl.expression, Diagnostics.Spread_types_may_only_be_created_from_object_types); typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } } @@ -28898,10 +28960,17 @@ namespace ts { prop = getPropertyOfType(apparentType, right.escapedText); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined + // here even if `Foo` is not a const enum. + // // The exceptions are: // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. - if (isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { + if (isIdentifier(left) && parentSymbol && ( + compilerOptions.isolatedModules || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & SymbolFlags.EnumMember && node.parent.kind === SyntaxKind.EnumMember)) || + shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node) + )) { markAliasReferenced(parentSymbol, node); } @@ -30338,9 +30407,15 @@ namespace ts { const parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - const error = hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 - : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise - : Diagnostics.Expected_0_arguments_but_got_1; + const isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node); + if (isVoidPromiseError && isInJSFile(node)) { + return getDiagnosticForCallNode(node, Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments); + } + const error = hasRestParameter + ? Diagnostics.Expected_at_least_0_arguments_but_got_1 + : isVoidPromiseError + ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : Diagnostics.Expected_0_arguments_but_got_1; if (min < args.length && args.length < max) { // between min and max, but with no matching overload return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); @@ -30445,6 +30520,7 @@ namespace ts { // decorators are applied to a declaration by the emitter, and not to an expression. const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; let argCheckMode = !isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? CheckMode.SkipContextSensitive : CheckMode.Normal; + argCheckMode |= checkMode & CheckMode.IsForStringLiteralArgumentCompletions; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the @@ -30670,7 +30746,7 @@ namespace ts { // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = CheckMode.Normal; + argCheckMode = checkMode & CheckMode.IsForStringLiteralArgumentCompletions; if (inferenceContext) { const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); @@ -31712,7 +31788,7 @@ namespace ts { const newSymbol = createSymbol(SymbolFlags.Alias, InternalSymbolName.Default); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); - newSymbol.target = resolveSymbol(symbol); + newSymbol.aliasTarget = resolveSymbol(symbol); memberTable.set(InternalSymbolName.Default, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray); } @@ -31978,13 +32054,13 @@ namespace ts { } function checkImportMetaProperty(node: MetaProperty) { - if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) { + if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) { if (getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.ESNext) { error(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ModuleKind.ES2020 && moduleKind !== ModuleKind.System) { - error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } const file = getSourceFileOfNode(node); Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag."); @@ -33014,16 +33090,37 @@ namespace ts { if (!hasParseDiagnostics(sourceFile)) { let span: TextSpan | undefined; if (!isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) span = getSpanOfTokenAtPosition(sourceFile, node.pos); + span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) { - span = getSpanOfTokenAtPosition(sourceFile, node.pos); - const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ModuleKind.Node16: + case ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ModuleKind.CommonJS) { + span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add( + createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level) + ); + break; + } + // fallthrough + case ModuleKind.ES2022: + case ModuleKind.ESNext: + case ModuleKind.System: + if (languageVersion >= ScriptTarget.ES2017) { + break; + } + // fallthrough + default: + span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add( + createFileDiagnostic(sourceFile, span.start, span.length, + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher + ) + ); + break; } } } @@ -34793,19 +34890,29 @@ namespace ts { if (constraintType && defaultType) { checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } - if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.ClassDeclaration || node.parent.kind === SyntaxKind.TypeAliasDeclaration) { + checkNodeDeferred(node); + addLazyDiagnostic(() => checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0)); + } + + function checkTypeParameterDeferred(node: TypeParameterDeclaration) { + if (isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent)) { + const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); const modifiers = getVarianceModifiers(typeParameter); - if (modifiers === ModifierFlags.In || modifiers === ModifierFlags.Out) { + if (modifiers) { const symbol = getSymbolOfNode(node.parent); - const source = createMarkerType(symbol, typeParameter, modifiers === ModifierFlags.Out ? markerSubType : markerSuperType); - const target = createMarkerType(symbol, typeParameter, modifiers === ModifierFlags.Out ? markerSuperType : markerSubType); - const saveVarianceTypeParameter = typeParameter; - varianceTypeParameter = typeParameter; - checkTypeAssignableTo(source, target, node, Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); - varianceTypeParameter = saveVarianceTypeParameter; + if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (ObjectFlags.Anonymous | ObjectFlags.Mapped))) { + error(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); + } + else if (modifiers === ModifierFlags.In || modifiers === ModifierFlags.Out) { + const source = createMarkerType(symbol, typeParameter, modifiers === ModifierFlags.Out ? markerSubType : markerSuperType); + const target = createMarkerType(symbol, typeParameter, modifiers === ModifierFlags.Out ? markerSuperType : markerSubType); + const saveVarianceTypeParameter = typeParameter; + varianceTypeParameter = typeParameter; + checkTypeAssignableTo(source, target, node, Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); + varianceTypeParameter = saveVarianceTypeParameter; + } } } - addLazyDiagnostic(() => checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0)); } function checkParameter(node: ParameterDeclaration) { @@ -35350,7 +35457,7 @@ namespace ts { superCallStatement = statement; break; } - if (!isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) { + if (nodeImmediatelyReferencesSuperOrThis(statement)) { break; } } @@ -35717,8 +35824,8 @@ namespace ts { if (node.assertions) { const override = getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -37336,7 +37443,7 @@ namespace ts { function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier | undefined) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node12 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { + if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { return; } @@ -38158,7 +38265,7 @@ namespace ts { return (use & IterationUse.PossiblyOutOfBounds) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; - function getIterationDiagnosticDetails(allowsStrings: boolean, downlevelIteration: boolean | undefined): [DiagnosticMessage, boolean] { + function getIterationDiagnosticDetails(allowsStrings: boolean, downlevelIteration: boolean | undefined): [error: DiagnosticMessage, maybeMissingAwait: boolean] { if (downlevelIteration) { return allowsStrings ? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] @@ -38168,7 +38275,7 @@ namespace ts { const yieldType = getIterationTypeOfIterable(use, IterationTypeKind.Yield, inputType, /*errorNode*/ undefined); if (yieldType) { - return [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable(inputType.symbol?.escapedName)) { @@ -40166,7 +40273,7 @@ namespace ts { function isConstantMemberAccess(node: Expression): node is AccessExpression { const type = getTypeOfExpression(node); - if(type === errorType) { + if (type === errorType) { return false; } @@ -40611,8 +40718,12 @@ namespace ts { const validForTypeAssertions = isExclusivelyTypeOnlyImportOrExport(declaration); const override = getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (!isNightly()) { + grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next); + } + + if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -41304,6 +41415,9 @@ namespace ts { case SyntaxKind.ClassExpression: checkClassExpressionDeferred(node as ClassExpression); break; + case SyntaxKind.TypeParameter: + checkTypeParameterDeferred(node as TypeParameterDeclaration); + break; case SyntaxKind.JsxSelfClosingElement: checkJsxSelfClosingElementDeferred(node as JsxSelfClosingElement); break; @@ -41803,7 +41917,7 @@ namespace ts { const symbol = getIntrinsicTagSymbol(name.parent as JsxOpeningLikeElement); return symbol === unknownSymbol ? undefined : symbol; } - const result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc, getHostSignatureFromJSDoc(name)); + const result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, getHostSignatureFromJSDoc(name)); if (!result && isJSDoc) { const container = findAncestor(name, or(isClassLike, isInterfaceDeclaration)); if (container) { @@ -41914,15 +42028,20 @@ namespace ts { return propertyDeclaration; } } - else if (isMetaProperty(parent)) { - const parentType = getTypeOfNode(parent); - const propertyDeclaration = getPropertyOfType(parentType, (node as Identifier).escapedText); - if (propertyDeclaration) { - return propertyDeclaration; - } - if (parent.keywordToken === SyntaxKind.NewKeyword) { + else if (isMetaProperty(parent) && parent.name === node) { + if (parent.keywordToken === SyntaxKind.NewKeyword && idText(node as Identifier) === "target") { + // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } + // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but + // we have a fake expression type made for other reasons already, whose transient `meta` + // member should more exactly be the kind of (declarationless) symbol we want. + // (See #44364 and #45031 for relevant implementation PRs) + if (parent.keywordToken === SyntaxKind.ImportKeyword && idText(node as Identifier) === "meta") { + return getGlobalImportMetaExpressionType().members!.get("meta" as __String); + } + // no other meta properties are valid syntax, thus no others should have symbols + return undefined; } } @@ -42083,7 +42202,7 @@ namespace ts { if (isDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration const symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isDeclarationNameOrImportPropertyName(node)) { @@ -42230,11 +42349,11 @@ namespace ts { const { leftSpread, rightSpread, syntheticOrigin } = symbol as TransientSymbol; return leftSpread ? [leftSpread, rightSpread!] : syntheticOrigin ? [syntheticOrigin] - : singleElementArray(tryGetAliasTarget(symbol)); + : singleElementArray(tryGetTarget(symbol)); } return undefined; } - function tryGetAliasTarget(symbol: Symbol): Symbol | undefined { + function tryGetTarget(symbol: Symbol): Symbol | undefined { let target: Symbol | undefined; let next: Symbol | undefined = symbol; while (next = getSymbolLinks(next).target) { @@ -42486,7 +42605,7 @@ namespace ts { if (links?.referenced) { return true; } - const target = getSymbolLinks(symbol!).target; // TODO: GH#18217 + const target = getSymbolLinks(symbol!).aliasTarget; // TODO: GH#18217 if (target && getEffectiveModifierFlags(node) & ModifierFlags.Export && target.flags & SymbolFlags.Value && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { @@ -42538,12 +42657,6 @@ namespace ts { hasSyntacticModifier(parameter, ModifierFlags.ParameterPropertyModifier); } - function isOptionalUninitializedParameter(parameter: ParameterDeclaration) { - return !!strictNullChecks && - isOptionalParameter(parameter) && - !parameter.initializer; - } - function isExpandoFunctionDeclaration(node: Declaration): boolean { const declaration = getParseTreeNode(node, isFunctionDeclaration); if (!declaration) { @@ -43507,8 +43620,7 @@ namespace ts { case SyntaxKind.OutKeyword: const inOutFlag = modifier.kind === SyntaxKind.InKeyword ? ModifierFlags.In : ModifierFlags.Out; const inOutText = modifier.kind === SyntaxKind.InKeyword ? "in" : "out"; - if (node.kind !== SyntaxKind.TypeParameter || (node.parent.kind !== SyntaxKind.InterfaceDeclaration && - node.parent.kind !== SyntaxKind.ClassDeclaration && node.parent.kind !== SyntaxKind.TypeAliasDeclaration)) { + if (node.kind !== SyntaxKind.TypeParameter || !(isInterfaceDeclaration(node.parent) || isClassLike(node.parent) || isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { @@ -43808,6 +43920,9 @@ namespace ts { } function checkGrammarExpressionWithTypeArguments(node: ExpressionWithTypeArguments | TypeQueryNode) { + if (isExpressionWithTypeArguments(node) && isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } @@ -44080,9 +44195,30 @@ namespace ts { diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) { - diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ModuleKind.Node16: + case ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ModuleKind.CommonJS) { + diagnostics.add( + createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level) + ); + break; + } + // fallthrough + case ModuleKind.ES2022: + case ModuleKind.ESNext: + case ModuleKind.System: + if (languageVersion >= ScriptTarget.ES2017) { + break; + } + // fallthrough + default: + diagnostics.add( + createDiagnosticForNode(forInOrOfStatement.awaitModifier, + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher + ) + ); + break; } } } @@ -44854,11 +44990,11 @@ namespace ts { function checkGrammarImportCallExpression(node: ImportCall): boolean { if (moduleKind === ModuleKind.ES2015) { - return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } const nodeArguments = node.arguments; @@ -44868,7 +45004,7 @@ namespace ts { if (nodeArguments.length > 1) { const assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6ed23d16e6b5a..b257d7aed4c7a 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -81,6 +81,7 @@ namespace ts { ["es2021.intl", "lib.es2021.intl.d.ts"], ["es2022.array", "lib.es2022.array.d.ts"], ["es2022.error", "lib.es2022.error.d.ts"], + ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], @@ -423,7 +424,7 @@ namespace ts { es2020: ModuleKind.ES2020, es2022: ModuleKind.ES2022, esnext: ModuleKind.ESNext, - node12: ModuleKind.Node12, + node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -781,7 +782,7 @@ namespace ts { type: new Map(getEntries({ node: ModuleResolutionKind.NodeJs, classic: ModuleResolutionKind.Classic, - node12: ModuleResolutionKind.Node12, + node16: ModuleResolutionKind.Node16, nodenext: ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -1263,7 +1264,7 @@ namespace ts { affectsModuleResolution: true, description: Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: Diagnostics.Language_and_Environment, - defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 4b1a1455e4486..dc8401539a7ac 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -5,7 +5,7 @@ namespace ts { // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - export const version = `${versionMajorMinor}.0-beta`; + export const version = `${versionMajorMinor}.1-rc`; /** * Type of objects whose values are all of the same type. diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3bc61d247ace5..bae97eb537518 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -900,6 +900,10 @@ "category": "Error", "code": 1308 }, + "The current file is a CommonJS module and cannot use 'await' at the top level.": { + "category": "Error", + "code": 1309 + }, "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.": { "category": "Error", "code": 1312 @@ -944,11 +948,11 @@ "category": "Error", "code": 1322 }, - "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.": { + "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.": { "category": "Error", "code": 1323 }, - "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'.": { + "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.": { "category": "Error", "code": 1324 }, @@ -956,7 +960,7 @@ "category": "Error", "code": 1325 }, - "Dynamic import cannot have type arguments.": { + "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments.": { "category": "Error", "code": 1326 }, @@ -1016,7 +1020,7 @@ "category": "Error", "code": 1342 }, - "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'.": { + "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.": { "category": "Error", "code": 1343 }, @@ -1140,7 +1144,7 @@ "category": "Message", "code": 1377 }, - "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1378 }, @@ -1348,7 +1352,7 @@ "category": "Error", "code": 1431 }, - "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1432 }, @@ -1420,7 +1424,7 @@ "category": "Error", "code": 1451 }, - "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`.": { + "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.": { "category": "Error", "code": 1452 }, @@ -1465,7 +1469,7 @@ "category": "Message", "code": 1475 }, - "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules.": { + "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules.": { "category": "Message", "code": 1476 }, @@ -1506,9 +1510,14 @@ "category": "Error", "code": 2207 }, - "This type parameter probably needs an `extends object` constraint.": { + + "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate.": { + "category": "Error", + "code": 2209 + }, + "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate.": { "category": "Error", - "code": 2208 + "code": 2210 }, "Duplicate identifier '{0}'.": { @@ -2511,10 +2520,7 @@ "category": "Error", "code": 2568 }, - "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.": { - "category": "Error", - "code": 2569 - }, + "Could not find name '{0}'. Did you mean '{1}'?": { "category": "Error", "code": 2570 @@ -2743,6 +2749,10 @@ "category": "Error", "code": 2636 }, + "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.": { + "category": "Error", + "code": 2637 + }, "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", @@ -3365,6 +3375,10 @@ "category": "Error", "code": 2809 }, + "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments.": { + "category": "Error", + "code": 2810 + }, "Initializer for property '{0}'": { "category": "Error", "code": 2811 @@ -3417,11 +3431,11 @@ "category": "Error", "code": 2833 }, - "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path.": { + "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.": { "category": "Error", "code": 2834 }, - "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?": { + "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?": { "category": "Error", "code": 2835 }, @@ -3866,6 +3880,10 @@ "category": "Error", "code": 4124 }, + "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.": { + "category": "Error", + "code": 4125 + }, "The current host does not support the '{0}' option.": { "category": "Error", @@ -6105,10 +6123,6 @@ "category": "Error", "code": 7061 }, - "JSON imports are experimental in ES module mode imports.": { - "category": "Error", - "code": 7062 - }, "You cannot rename this element.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a0fbb74b33be1..c83713750f2a6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -167,7 +167,7 @@ namespace ts { } function getOwnOutputFileNames(configFile: ParsedCommandLine, inputFileName: string, ignoreCase: boolean, addOutput: ReturnType["addOutput"], getCommonSourceDirectory?: () => string) { - if (fileExtensionIs(inputFileName, Extension.Dts)) return; + if (isDeclarationFileName(inputFileName)) return; const js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); if (fileExtensionIs(inputFileName, Extension.Json)) return; @@ -219,7 +219,7 @@ namespace ts { export function getCommonSourceDirectoryOfConfig({ options, fileNames }: ParsedCommandLine, ignoreCase: boolean): string { return getCommonSourceDirectory( options, - () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensionsFlat)) && !fileExtensionIs(file, Extension.Dts)), + () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensionsFlat)) && !isDeclarationFileName(file)), getDirectoryPath(normalizeSlashes(Debug.checkDefined(options.configFilePath))), createGetCanonicalFileName(!ignoreCase) ); @@ -263,7 +263,7 @@ namespace ts { const getCommonSourceDirectory = memoize(() => getCommonSourceDirectoryOfConfig(configFile, ignoreCase)); for (const inputFileName of configFile.fileNames) { - if (fileExtensionIs(inputFileName, Extension.Dts)) continue; + if (isDeclarationFileName(inputFileName)) continue; const jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; if (fileExtensionIs(inputFileName, Extension.Json)) continue; @@ -531,6 +531,7 @@ namespace ts { printer.writeFile(sourceFile!, writer, sourceMapGenerator); } + let sourceMapUrlPos; if (sourceMapGenerator) { if (sourceMapDataList) { sourceMapDataList.push({ @@ -548,6 +549,7 @@ namespace ts { if (sourceMappingURL) { if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); + sourceMapUrlPos = writer.getTextPos(); writer.writeComment(`//# ${"sourceMappingURL"}=${sourceMappingURL}`); // Tools can sometimes see this line as a source mapping url comment } @@ -562,7 +564,7 @@ namespace ts { } // Write the output file - writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); + writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos }); // Reset state writer.clear(); @@ -1170,7 +1172,7 @@ namespace ts { } function getCurrentLineMap() { - return currentLineMap || (currentLineMap = getLineStarts(currentSourceFile!)); + return currentLineMap || (currentLineMap = getLineStarts(Debug.checkDefined(currentSourceFile))); } function emit(node: Node, parenthesizerRule?: (node: Node) => Node): void; @@ -1815,7 +1817,7 @@ namespace ts { const numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (let i = 0; i < numNodes; i++) { const currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; - const sourceFile = isSourceFile(currentNode) ? currentNode : isUnparsedSource(currentNode) ? undefined : currentSourceFile!; + const sourceFile = isSourceFile(currentNode) ? currentNode : isUnparsedSource(currentNode) ? undefined : currentSourceFile; const shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && hasRecordedExternalHelpers(sourceFile)); const shouldBundle = (isSourceFile(currentNode) || isUnparsedSource(currentNode)) && !isOwnFileEmit; const helpers = isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); @@ -2465,7 +2467,7 @@ namespace ts { } const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; - const allowTrailingComma = currentSourceFile!.languageVersion >= ScriptTarget.ES5 && !isJsonSourceFile(currentSourceFile!) ? ListFormat.AllowTrailingComma : ListFormat.None; + const allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= ScriptTarget.ES5 && !isJsonSourceFile(currentSourceFile) ? ListFormat.AllowTrailingComma : ListFormat.None; emitList(node, node.properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine); if (indentedFlag) { @@ -2880,7 +2882,7 @@ namespace ts { emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) - if (!isJsonSourceFile(currentSourceFile!) || nodeIsSynthesized(node.expression)) { + if (!currentSourceFile || !isJsonSourceFile(currentSourceFile) || nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } @@ -3207,7 +3209,7 @@ namespace ts { return false; } - if (!nodeIsSynthesized(body) && !rangeIsOnSingleLine(body, currentSourceFile!)) { + if (!nodeIsSynthesized(body) && currentSourceFile && !rangeIsOnSingleLine(body, currentSourceFile)) { return false; } @@ -3238,12 +3240,7 @@ namespace ts { ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); - } - else { - emitBlockFunctionBody(body); - } + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(SyntaxKind.CloseBraceToken, body.statements.end, writePunctuation, body); @@ -3701,9 +3698,10 @@ namespace ts { statements.length === 1 && ( // treat synthesized nodes as located on the same line for emit purposes + !currentSourceFile || nodeIsSynthesized(parentNode) || nodeIsSynthesized(statements[0]) || - rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile!) + rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile) ); let format = ListFormat.CaseOrDefaultClauseStatements; @@ -3958,16 +3956,14 @@ namespace ts { function emitSourceFile(node: SourceFile) { writeLine(); const statements = node.statements; - if (emitBodyWithDetachedComments) { - // Emit detached comment if there are no prologue directives or if the first node is synthesized. - // The synthesized node will have no leading comment so some comments may be missed. - const shouldEmitDetachedComment = statements.length === 0 || - !isPrologueDirective(statements[0]) || - nodeIsSynthesized(statements[0]); - if (shouldEmitDetachedComment) { - emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); - return; - } + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + const shouldEmitDetachedComment = statements.length === 0 || + !isPrologueDirective(statements[0]) || + nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; } emitSourceFileWorker(node); } @@ -4369,7 +4365,7 @@ namespace ts { if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & ListFormat.MultiLine && !(preserveSourceNewlines && (!parentNode || rangeIsOnSingleLine(parentNode, currentSourceFile!)))) { + if (format & ListFormat.MultiLine && !(preserveSourceNewlines && (!parentNode || currentSourceFile && rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & ListFormat.SpaceBetweenBraces && !(format & ListFormat.NoSpaceIfEmpty)) { @@ -4673,7 +4669,7 @@ namespace ts { const firstChild = children[0]; if (firstChild === undefined) { - return !parentNode || rangeIsOnSingleLine(parentNode, currentSourceFile!) ? 0 : 1; + return !parentNode || currentSourceFile && rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -4697,7 +4693,7 @@ namespace ts { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (parentNode && + if (currentSourceFile && parentNode && !positionIsSynthesized(parentNode.pos) && !nodeIsSynthesized(firstChild) && (!firstChild.parent || getOriginalNode(firstChild.parent) === getOriginalNode(parentNode)) @@ -4710,7 +4706,7 @@ namespace ts { currentSourceFile!, includeComments)); } - return rangeStartPositionsAreOnSameLine(parentNode, firstChild, currentSourceFile!) ? 0 : 1; + return rangeStartPositionsAreOnSameLine(parentNode, firstChild, currentSourceFile) ? 0 : 1; } if (synthesizedNodeStartsOnNewLine(firstChild, format)) { return 1; @@ -4728,7 +4724,7 @@ namespace ts { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!nodeIsSynthesized(previousNode) && !nodeIsSynthesized(nextNode)) { + else if (currentSourceFile && !nodeIsSynthesized(previousNode) && !nodeIsSynthesized(nextNode)) { if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { return getEffectiveLines( includeComments => getLinesBetweenRangeEndAndRangeStart( @@ -4743,7 +4739,7 @@ namespace ts { // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the // effective source lines between two sibling nodes. else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { - return rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile!) ? 0 : 1; + return rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. @@ -4767,9 +4763,9 @@ namespace ts { const lastChild = lastOrUndefined(children); if (lastChild === undefined) { - return !parentNode || rangeIsOnSingleLine(parentNode, currentSourceFile!) ? 0 : 1; + return !parentNode || currentSourceFile && rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (parentNode && !positionIsSynthesized(parentNode.pos) && !nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (currentSourceFile && parentNode && !positionIsSynthesized(parentNode.pos) && !nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { const end = isNodeArray(children) && !positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines( @@ -4779,7 +4775,7 @@ namespace ts { currentSourceFile!, includeComments)); } - return rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile!) ? 0 : 1; + return rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile) ? 0 : 1; } if (synthesizedNodeStartsOnNewLine(lastChild, format)) { return 1; @@ -4857,7 +4853,7 @@ namespace ts { return 1; } - if (!nodeIsSynthesized(parent) && !nodeIsSynthesized(node1) && !nodeIsSynthesized(node2)) { + if (currentSourceFile && !nodeIsSynthesized(parent) && !nodeIsSynthesized(node1) && !nodeIsSynthesized(node2)) { if (preserveSourceNewlines) { return getEffectiveLines( includeComments => getLinesBetweenRangeEndAndRangeStart( @@ -4866,7 +4862,7 @@ namespace ts { currentSourceFile!, includeComments)); } - return rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile!) ? 0 : 1; + return rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1; } return 0; @@ -4874,7 +4870,7 @@ namespace ts { function isEmptyBlock(block: BlockLike) { return block.statements.length === 0 - && rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile!); + && (!currentSourceFile || rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node: Node) { @@ -4885,21 +4881,27 @@ namespace ts { return node; } - function getTextOfNode(node: Node, includeTrivia?: boolean): string { + function getTextOfNode(node: Identifier | PrivateIdentifier | LiteralExpression, includeTrivia?: boolean): string { if (isGeneratedIdentifier(node)) { return generateName(node); } - else if ((isIdentifier(node) || isPrivateIdentifier(node)) && (nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && getSourceFileOfNode(node) !== getOriginalNode(currentSourceFile)))) { - return idText(node); + if (isStringLiteral(node) && node.textSourceNode) { + return getTextOfNode(node.textSourceNode, includeTrivia); } - else if (node.kind === SyntaxKind.StringLiteral && (node as StringLiteral).textSourceNode) { - return getTextOfNode((node as StringLiteral).textSourceNode!, includeTrivia); + const sourceFile = currentSourceFile; // const needed for control flow + const canUseSourceFile = !!sourceFile && !!node.parent && !nodeIsSynthesized(node); + if (isMemberName(node)) { + if (!canUseSourceFile || getSourceFileOfNode(node) !== getOriginalNode(sourceFile)) { + return idText(node); + } } - else if (isLiteralExpression(node) && (nodeIsSynthesized(node) || !node.parent)) { - return node.text; + else { + Debug.assertNode(node, isLiteralExpression); // not strictly necessary + if (!canUseSourceFile) { + return node.text; + } } - - return getSourceTextOfNodeFromSourceFile(currentSourceFile!, node, includeTrivia); + return getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node: LiteralLikeNode, neverAsciiEscape: boolean | undefined, jsxAttributeEscape: boolean): string { @@ -4921,7 +4923,7 @@ namespace ts { | (printerOptions.terminateUnterminatedLiterals ? GetLiteralTextFlags.TerminateUnterminatedLiterals : 0) | (printerOptions.target && printerOptions.target === ScriptTarget.ESNext ? GetLiteralTextFlags.AllowNumericSeparator : 0); - return getLiteralText(node, currentSourceFile!, flags); + return getLiteralText(node, currentSourceFile, flags); } /** @@ -5244,7 +5246,7 @@ namespace ts { switch (node.kind) { case SyntaxKind.Identifier: return makeUniqueName( - getTextOfNode(node), + getTextOfNode(node as Identifier), isUniqueName, !!(flags! & GeneratedIdentifierFlags.Optimistic), !!(flags! & GeneratedIdentifierFlags.ReservedInNestedScopes) @@ -5546,7 +5548,7 @@ namespace ts { } function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { - if (!shouldWriteComment(currentSourceFile!.text, commentPos)) return; + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; if (!hasWrittenComment) { emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); hasWrittenComment = true; @@ -5554,7 +5556,7 @@ namespace ts { // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space emitPos(commentPos); - writeCommentRange(currentSourceFile!.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); if (hasTrailingNewLine) { @@ -5578,14 +5580,14 @@ namespace ts { } function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) { - if (!shouldWriteComment(currentSourceFile!.text, commentPos)) return; + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { writer.writeSpace(" "); } emitPos(commentPos); - writeCommentRange(currentSourceFile!.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); if (hasTrailingNewLine) { @@ -5603,10 +5605,11 @@ namespace ts { } function emitTrailingCommentOfPositionNoNewline(commentPos: number, commentEnd: number, kind: SyntaxKind) { + if (!currentSourceFile) return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); - writeCommentRange(currentSourceFile!.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); if (kind === SyntaxKind.SingleLineCommentTrivia) { @@ -5615,10 +5618,11 @@ namespace ts { } function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) { + if(!currentSourceFile) return; // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); - writeCommentRange(currentSourceFile!.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); if (hasTrailingNewLine) { @@ -5653,6 +5657,7 @@ namespace ts { } function forEachLeadingCommentWithoutDetachedComments(cb: (commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) => void) { + if (!currentSourceFile) return; // get the leading comments from detachedPos const pos = last(detachedCommentsInfo!).detachedCommentEndPos; if (detachedCommentsInfo!.length - 1) { @@ -5662,11 +5667,11 @@ namespace ts { detachedCommentsInfo = undefined; } - forEachLeadingCommentRange(currentSourceFile!.text, pos, cb, /*state*/ pos); + forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); } function emitDetachedCommentsAndUpdateCommentsInfo(range: TextRange) { - const currentDetachedCommentInfo = emitDetachedComments(currentSourceFile!.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + const currentDetachedCommentInfo = currentSourceFile && emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); if (currentDetachedCommentInfo) { if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -5678,7 +5683,7 @@ namespace ts { } function emitComment(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) { - if (!shouldWriteComment(currentSourceFile!.text, commentPos)) return; + if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos)) return; emitPos(commentPos); writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -5690,7 +5695,7 @@ namespace ts { * @return true if the comment is a triple-slash comment else false */ function isTripleSlashComment(commentPos: number, commentEnd: number) { - return isRecognizedTripleSlashComment(currentSourceFile!.text, commentPos, commentEnd); + return !!currentSourceFile && isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index cbeb8df5e5b25..9028c521a1384 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -5275,7 +5275,7 @@ namespace ts { hasNoDefaultLib: boolean, libReferences: readonly FileReference[] ) { - const node = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile) as Mutable; + const node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile)) as Mutable; for (const p in source) { if (p === "emitNode" || hasProperty(node, p) || !hasProperty(source, p)) continue; (node as any)[p] = (source as any)[p]; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 104223d1e750d..8f466c0495aee 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -69,7 +69,8 @@ namespace ts { JavaScript, /** '.js' or '.jsx' */ Json, /** '.json' */ TSConfig, /** '.json' with `tsconfig` used instead of `index` */ - DtsOnly /** Only '.d.ts' */ + DtsOnly, /** Only '.d.ts' */ + TsOnly, /** '.[cm]tsx?' but not .d.ts variants */ } interface PathAndPackageId { @@ -85,14 +86,15 @@ namespace ts { return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean | undefined, failedLookupLocations: string[], resultFromCache: ResolvedModuleWithFailedLookupLocations | undefined): ResolvedModuleWithFailedLookupLocations { + function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean | undefined, failedLookupLocations: string[], diagnostics: Diagnostic[], resultFromCache: ResolvedModuleWithFailedLookupLocations | undefined): ResolvedModuleWithFailedLookupLocations { if (resultFromCache) { resultFromCache.failedLookupLocations.push(...failedLookupLocations); return resultFromCache; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations + failedLookupLocations, + resolutionDiagnostics: diagnostics }; } @@ -106,6 +108,8 @@ namespace ts { packageJsonInfoCache: PackageJsonInfoCache | undefined; features: NodeResolutionFeatures; conditions: string[]; + requestContainingDirectory: string | undefined; + reportDiagnostic: DiagnosticReporter; } /** Just the fields that we use for module resolution. */ @@ -347,13 +351,24 @@ namespace ts { // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ModuleKind.ESNext && (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ModuleKind.ESNext && (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } const conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; - const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features, conditions }; + const diagnostics: Diagnostic[] = []; + const moduleResolutionState: ModuleResolutionState = { + compilerOptions: options, + host, + traceEnabled, + failedLookupLocations, + packageJsonInfoCache: cache, + features, + conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: diag => void diagnostics.push(diag), + }; let resolved = primaryLookup(); let primary = true; if (!resolved) { @@ -373,7 +388,7 @@ namespace ts { isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective, failedLookupLocations }; + result = { resolvedTypeReferenceDirective, failedLookupLocations, resolutionDiagnostics: diagnostics }; perFolderCache?.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); return result; @@ -443,7 +458,7 @@ namespace ts { } function getDefaultNodeResolutionFeatures(options: CompilerOptions) { - return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -467,6 +482,8 @@ namespace ts { packageJsonInfoCache: cache?.getPackageJsonInfoCache(), conditions: emptyArray, features: NodeResolutionFeatures.None, + requestContainingDirectory: containingDirectory, + reportDiagnostic: noop }; return forEachAncestorDirectory(containingDirectory, ancestorDirectory => { @@ -949,8 +966,8 @@ namespace ts { case ModuleKind.CommonJS: moduleResolution = ModuleResolutionKind.NodeJs; break; - case ModuleKind.Node12: - moduleResolution = ModuleResolutionKind.Node12; + case ModuleKind.Node16: + moduleResolution = ModuleResolutionKind.Node16; break; case ModuleKind.NodeNext: moduleResolution = ModuleResolutionKind.NodeNext; @@ -971,8 +988,8 @@ namespace ts { perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -1230,22 +1247,22 @@ namespace ts { // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names Exports = 1 << 3, // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 ExportsPatternTrailers = 1 << 4, AllFeatures = Imports | SelfName | Exports | ExportsPatternTrailers, - Node12Default = Imports | SelfName | Exports, + Node16Default = Imports | SelfName | Exports | ExportsPatternTrailers, NodeNextDefault = AllFeatures, EsmMode = 1 << 5, } - function node12ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, + function node16ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations { return nodeNextModuleNameResolverWorker( - NodeResolutionFeatures.Node12Default, + NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, @@ -1290,15 +1307,33 @@ namespace ts { export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; /* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations; // eslint-disable-line @typescript-eslint/unified-signatures export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations { - return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + let extensions; + if (lookupConfig) { + extensions = tsconfigExtensions; + } + else if (compilerOptions.noDtsResolution) { + extensions = [Extensions.TsOnly]; + if (compilerOptions.allowJs) extensions.push(Extensions.JavaScript); + if (compilerOptions.resolveJsonModule) extensions.push(Extensions.Json); + } + else { + extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, extensions: Extensions[], redirectedReference: ResolvedProjectReference | undefined): ResolvedModuleWithFailedLookupLocations { const traceEnabled = isTraceEnabled(compilerOptions, host); const failedLookupLocations: string[] = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). + const conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + if (compilerOptions.noDtsResolution) { + conditions.pop(); + } + + const diagnostics: Diagnostic[] = []; const state: ModuleResolutionState = { compilerOptions, host, @@ -1306,11 +1341,13 @@ namespace ts { failedLookupLocations, packageJsonInfoCache: cache, features, - conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + conditions, + requestContainingDirectory: containingDirectory, + reportDiagnostic: diag => void diagnostics.push(diag), }; const result = forEach(extensions, ext => tryResolve(ext)); - return createResolvedModuleWithFailedLookupLocations(result?.value?.resolved, result?.value?.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(result?.value?.resolved, result?.value?.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions: Extensions): SearchResult<{ resolved: Resolved, isExternalLibraryImport: boolean }> { const loader: ResolutionKindSpecificLoader = (extensions, candidate, onlyRecordFailures, state) => nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); @@ -1498,9 +1535,9 @@ namespace ts { } function loadJSOrExactTSFileName(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { - if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && fileExtensionIsOneOf(candidate, [Extension.Dts, Extension.Dcts, Extension.Dmts])) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) { const result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: forEach([Extension.Dts, Extension.Dcts, Extension.Dmts], e => fileExtensionIs(candidate, e) ? e : undefined)! } : undefined; + return result !== undefined ? { path: candidate, ext: tryExtractTSExtension(candidate) as Extension } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); @@ -1533,20 +1570,22 @@ namespace ts { default: return tryExtension(Extension.Dts); } case Extensions.TypeScript: + case Extensions.TsOnly: + const useDts = extensions === Extensions.TypeScript; switch (originalExtension) { case Extension.Mjs: case Extension.Mts: case Extension.Dmts: - return tryExtension(Extension.Mts) || tryExtension(Extension.Dmts); + return tryExtension(Extension.Mts) || (useDts ? tryExtension(Extension.Dmts) : undefined); case Extension.Cjs: case Extension.Cts: case Extension.Dcts: - return tryExtension(Extension.Cts) || tryExtension(Extension.Dcts); + return tryExtension(Extension.Cts) || (useDts ? tryExtension(Extension.Dcts) : undefined); case Extension.Json: candidate += Extension.Json; - return tryExtension(Extension.Dts); + return useDts ? tryExtension(Extension.Dts) : undefined; default: - return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts); + return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || (useDts ? tryExtension(Extension.Dts) : undefined); } case Extensions.JavaScript: switch (originalExtension) { @@ -1635,6 +1674,8 @@ namespace ts { packageJsonInfoCache: cache?.getPackageJsonInfoCache(), conditions: ["node", "require", "types"], features, + requestContainingDirectory: packageJsonInfo.packageDirectory, + reportDiagnostic: noop }; const requireResolution = loadNodeModuleFromDirectoryWorker( extensions, @@ -1744,6 +1785,8 @@ namespace ts { packageJsonInfoCache: PackageJsonInfoCache | undefined; features: number; conditions: never[]; + requestContainingDirectory: string | undefined; + reportDiagnostic: DiagnosticReporter } = { host, compilerOptions: options, @@ -1752,6 +1795,8 @@ namespace ts { packageJsonInfoCache, features: 0, conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: noop }; const parts = getPathComponents(fileName); parts.pop(); @@ -1813,6 +1858,7 @@ namespace ts { switch (extensions) { case Extensions.JavaScript: case Extensions.Json: + case Extensions.TsOnly: packageFile = readPackageJsonMainField(jsonContent, candidate, state); break; case Extensions.TypeScript: @@ -1893,14 +1939,16 @@ namespace ts { function extensionIsOk(extensions: Extensions, extension: Extension): boolean { switch (extensions) { case Extensions.JavaScript: - return extension === Extension.Js || extension === Extension.Jsx; + return extension === Extension.Js || extension === Extension.Jsx || extension === Extension.Mjs || extension === Extension.Cjs; case Extensions.TSConfig: case Extensions.Json: return extension === Extension.Json; case Extensions.TypeScript: - return extension === Extension.Ts || extension === Extension.Tsx || extension === Extension.Dts; + return extension === Extension.Ts || extension === Extension.Tsx || extension === Extension.Mts || extension === Extension.Cts || extension === Extension.Dts || extension === Extension.Dmts || extension === Extension.Dcts; + case Extensions.TsOnly: + return extension === Extension.Ts || extension === Extension.Tsx || extension === Extension.Mts || extension === Extension.Cts; case Extensions.DtsOnly: - return extension === Extension.Dts; + return extension === Extension.Dts || extension === Extension.Dmts || extension === Extension.Dcts; } } @@ -2089,8 +2137,9 @@ namespace ts { } return toSearchResult(/*value*/ undefined); } - const finalPath = getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, state.host.getCurrentDirectory?.()); - + const finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath); + const inputLink = tryLoadInputFileForPath(finalPath, subpath, combinePaths(scope.packageDirectory, "package.json"), isImports); + if (inputLink) return inputLink; return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); } else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null @@ -2131,6 +2180,134 @@ namespace ts { trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); } return toSearchResult(/*value*/ undefined); + + function toAbsolutePath(path: string): string; + function toAbsolutePath(path: string | undefined): string | undefined; + function toAbsolutePath(path: string | undefined): string | undefined { + if (path === undefined) return path; + return hostGetCanonicalFileName({ useCaseSensitiveFileNames })(getNormalizedAbsolutePath(path, state.host.getCurrentDirectory?.())); + } + + function combineDirectoryPath(root: string, dir: string) { + return ensureTrailingDirectorySeparator(combinePaths(root, dir)); + } + + function useCaseSensitiveFileNames() { + return !state.host.useCaseSensitiveFileNames ? true : + typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames : + state.host.useCaseSensitiveFileNames(); + } + + function tryLoadInputFileForPath(finalPath: string, entry: string, packagePath: string, isImports: boolean) { + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json) + && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) + && finalPath.indexOf("/node_modules/") === -1 + && (state.compilerOptions.configFile ? startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true) + ) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + + const getCanonicalFileName = hostGetCanonicalFileName({ useCaseSensitiveFileNames }); + const commonSourceDirGuesses: string[] = []; + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) { + const commonDir = toAbsolutePath(getCommonSourceDirectory(state.compilerOptions, () => [], state.host.getCurrentDirectory?.() || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + } + else if (state.requestContainingDirectory) { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory + + const requestingFile = toAbsolutePath(combinePaths(state.requestContainingDirectory, "index.ts")); + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + const commonDir = toAbsolutePath(getCommonSourceDirectory(state.compilerOptions, () => [requestingFile, toAbsolutePath(packagePath)], state.host.getCurrentDirectory?.() || "", getCanonicalFileName)); + commonSourceDirGuesses.push(commonDir); + + let fragment = ensureTrailingDirectorySeparator(commonDir); + while (fragment && fragment.length > 1) { + const parts = getPathComponents(fragment); + parts.pop(); // remove a directory + const commonDir = getPathFromPathComponents(parts); + commonSourceDirGuesses.unshift(commonDir); + fragment = ensureTrailingDirectorySeparator(commonDir); + } + } + if (commonSourceDirGuesses.length > 1) { + state.reportDiagnostic(createCompilerDiagnostic( + isImports + ? Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate + : Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, + entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath + )); + } + for (const commonSourceDirGuess of commonSourceDirGuesses) { + const candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess); + for (const candidateDir of candidateDirectories) { + if (startsWith(finalPath, candidateDir)) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + const pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator + const possibleInputBase = combinePaths(commonSourceDirGuess, pathFragment); + const jsAndDtsExtensions = [Extension.Mjs, Extension.Cjs, Extension.Js, Extension.Json, Extension.Dmts, Extension.Dcts, Extension.Dts]; + for (const ext of jsAndDtsExtensions) { + if (fileExtensionIs(possibleInputBase, ext)) { + const inputExts = getPossibleOriginalInputExtensionForExtension(possibleInputBase); + for (const possibleExt of inputExts) { + const possibleInputWithInputExtension = changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames()); + if ((extensions === Extensions.TypeScript && hasJSFileExtension(possibleInputWithInputExtension)) || + (extensions === Extensions.JavaScript && hasTSFileExtension(possibleInputWithInputExtension))) { + continue; + } + if (state.host.fileExists(possibleInputWithInputExtension)) { + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state))); + } + } + } + } + } + } + } + } + return undefined; + + function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess: string) { + // Config file ouput paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + const currentDir = state.compilerOptions.configFile ? state.host.getCurrentDirectory?.() || "" : commonSourceDirGuess; + const candidateDirectories = []; + if (state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir))); + } + if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) { + candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir))); + } + return candidateDirectories; + } + } } } @@ -2351,12 +2528,13 @@ namespace ts { export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations { const traceEnabled = isTraceEnabled(compilerOptions, host); const failedLookupLocations: string[] = []; - const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; const containingDirectory = getDirectoryPath(containingFile); + const diagnostics: Diagnostic[] = []; + const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: diag => void diagnostics.push(diag) }; const resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); function tryResolve(extensions: Extensions): SearchResult { const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); @@ -2401,9 +2579,10 @@ namespace ts { trace(host, Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } const failedLookupLocations: string[] = []; - const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + const diagnostics: Diagnostic[] = []; + const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: diag => void diagnostics.push(diag) }; const resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache); } /** diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 270bee0048ec8..ed8d9f90b0ae2 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -41,7 +41,7 @@ namespace ts.moduleSpecifiers { } function isFormatRequiringExtensions(compilerOptions: CompilerOptions, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 + if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { return false; } @@ -105,7 +105,7 @@ namespace ts.moduleSpecifiers { const info = getInfo(importingSourceFile.path, host); const modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options); return firstDefined(modulePaths, - modulePath => tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode)); + modulePath => tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode)); } function getModuleSpecifierWorker( @@ -120,7 +120,7 @@ namespace ts.moduleSpecifiers { ): string { const info = getInfo(importingSourceFileName, host); const modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); - return firstDefined(modulePaths, modulePath => tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode)) || + return firstDefined(modulePaths, modulePath => tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode)) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } @@ -248,7 +248,7 @@ namespace ts.moduleSpecifiers { let pathsSpecifiers: string[] | undefined; let relativeSpecifiers: string[] | undefined; for (const modulePath of modulePaths) { - const specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); + const specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); nodeModulesSpecifiers = append(nodeModulesSpecifiers, specifier); if (specifier && modulePath.isRedirect) { // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", @@ -666,7 +666,7 @@ namespace ts.moduleSpecifiers { : removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, sourceDirectory }: Info, importingSourceFile: SourceFile , host: ModuleSpecifierResolutionHost, options: CompilerOptions, packageNameOnly?: boolean, overrideMode?: ModuleKind.ESNext | ModuleKind.CommonJS): string | undefined { + function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, sourceDirectory }: Info, importingSourceFile: SourceFile , host: ModuleSpecifierResolutionHost, options: CompilerOptions, userPreferences: UserPreferences, packageNameOnly?: boolean, overrideMode?: ModuleKind.ESNext | ModuleKind.CommonJS): string | undefined { if (!host.fileExists || !host.readFile) { return undefined; } @@ -680,8 +680,9 @@ namespace ts.moduleSpecifiers { let moduleSpecifier = path; let isPackageRootPath = false; if (!packageNameOnly) { + const preferences = getPreferences(host, userPreferences, options, importingSourceFile); let packageRootIndex = parts.packageRootIndex; - let moduleFileNameForExtensionless: string | undefined; + let moduleFileName: string | undefined; while (true) { // If the module could be imported by a directory name, use that directory's name const { moduleFileToTry, packageRootPath, blockedByExports, verbatimFromExports } = tryDirectoryWithPackageJson(packageRootIndex); @@ -698,12 +699,12 @@ namespace ts.moduleSpecifiers { isPackageRootPath = true; break; } - if (!moduleFileNameForExtensionless) moduleFileNameForExtensionless = moduleFileToTry; + if (!moduleFileName) moduleFileName = moduleFileToTry; // try with next level of directory packageRootIndex = path.indexOf(directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); break; } } @@ -734,7 +735,7 @@ namespace ts.moduleSpecifiers { const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { const packageJsonContent = cachedPackageJson?.packageJsonContent || JSON.parse(host.readFile!(packageJsonPath)!); - if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` @@ -768,7 +769,7 @@ namespace ts.moduleSpecifiers { } } // If the file is the main module, it can be imported by the package name - const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; if (isString(mainFileRelative)) { const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (removeFileExtension(mainExportFile) === removeFileExtension(getCanonicalFileName(moduleFileToTry))) { @@ -776,20 +777,14 @@ namespace ts.moduleSpecifiers { } } } - return { moduleFileToTry }; - } - - function getExtensionlessFileName(path: string): string { - // We still have a file name - remove the extension - const fullModulePathWithoutExtension = removeFileExtension(path); - - // If the file is /index, it can be imported by its directory name - // IFF there is not _also_ a file by the same name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + else { + // No package.json exists; an index.js will still resolve as the package name + const fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1)); + if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") { + return { moduleFileToTry, packageRootPath }; + } } - - return fullModulePathWithoutExtension; + return { moduleFileToTry }; } } @@ -812,13 +807,19 @@ namespace ts.moduleSpecifiers { }); } - function removeExtensionAndIndexPostFix(fileName: string, ending: Ending, options: CompilerOptions): string { + function removeExtensionAndIndexPostFix(fileName: string, ending: Ending, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) return fileName; const noExtension = removeFileExtension(fileName); if (fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Dcts, Extension.Cts])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { case Ending.Minimal: - return removeSuffix(noExtension, "/index"); + const withoutIndex = removeSuffix(noExtension, "/index"); + if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { + // Can't remove index if there's a file by the same name as the directory. + // Probably more callers should pass `host` so we can determine this? + return noExtension; + } + return withoutIndex; case Ending.Index: return noExtension; case Ending.JsExtension: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7642612e27a44..dd1e7f6431a7e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -683,7 +683,7 @@ namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -944,7 +944,7 @@ namespace ts { initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, ScriptKind.JS); // Prime the scanner. nextToken(); - const entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false); + const entityName = parseEntityName(/*allowReservedWords*/ true); const isInvalid = token() === SyntaxKind.EndOfFileToken && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; @@ -2745,6 +2745,7 @@ namespace ts { const startPos = scanner.getStartPos(); const result = parseListElement(kind, parseElement); if (!result) { + parsingContext = saveParsingContext; return undefined; } list.push(result as NonNullable); @@ -2829,7 +2830,7 @@ namespace ts { return createMissingList(); } - function parseEntityName(allowReservedWords: boolean, allowPrivateIdentifiers: boolean, diagnosticMessage?: DiagnosticMessage): EntityName { + function parseEntityName(allowReservedWords: boolean, diagnosticMessage?: DiagnosticMessage): EntityName { const pos = getNodePos(); let entity: EntityName = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); let dotPos = getNodePos(); @@ -2843,7 +2844,7 @@ namespace ts { entity = finishNode( factory.createQualifiedName( entity, - parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers) as Identifier + parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false) as Identifier ), pos ); @@ -3028,7 +3029,7 @@ namespace ts { // TYPES function parseEntityNameOfTypeReference() { - return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, Diagnostics.Type_expected); + return parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { @@ -3188,8 +3189,9 @@ namespace ts { function parseTypeQuery(): TypeQueryNode { const pos = getNodePos(); parseExpected(SyntaxKind.TypeOfKeyword); - const entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true); - const typeArguments = tryParseTypeArguments(); + const entityName = parseEntityName(/*allowReservedWords*/ true); + // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. + const typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos); } @@ -4289,10 +4291,10 @@ namespace ts { } const pos = getNodePos(); - let expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + let expr = parseAssignmentExpressionOrHigher(); let operatorToken: BinaryOperatorToken; while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos); + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); } if (saveDecoratorContext) { @@ -4302,10 +4304,10 @@ namespace ts { } function parseInitializer(): Expression | undefined { - return parseOptional(SyntaxKind.EqualsToken) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined; + return parseOptional(SyntaxKind.EqualsToken) ? parseAssignmentExpressionOrHigher() : undefined; } - function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction: boolean): Expression { + function parseAssignmentExpressionOrHigher(): Expression { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -4333,7 +4335,7 @@ namespace ts { // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. - const arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction); + const arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); if (arrowExpression) { return arrowExpression; } @@ -4354,7 +4356,7 @@ namespace ts { // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. if (expr.kind === SyntaxKind.Identifier && token() === SyntaxKind.EqualsGreaterThanToken) { - return parseSimpleArrowFunctionExpression(pos, expr as Identifier, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); + return parseSimpleArrowFunctionExpression(pos, expr as Identifier, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -4364,7 +4366,7 @@ namespace ts { // Note: we call reScanGreaterToken so that we get an appropriately merged token // for cases like `> > =` becoming `>>=` if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); } // It wasn't an assignment or a lambda. This is a conditional expression: @@ -4418,7 +4420,7 @@ namespace ts { return finishNode( factory.createYieldExpression( parseOptionalToken(SyntaxKind.AsteriskToken), - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) + parseAssignmentExpressionOrHigher() ), pos ); @@ -4430,7 +4432,7 @@ namespace ts { } } - function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, disallowReturnTypeInArrowFunction: boolean, asyncModifier?: NodeArray | undefined): ArrowFunction { + function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, asyncModifier?: NodeArray | undefined): ArrowFunction { Debug.assert(token() === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); const parameter = factory.createParameterDeclaration( /*decorators*/ undefined, @@ -4445,12 +4447,12 @@ namespace ts { const parameters = createNodeArray([parameter], parameter.pos, parameter.end); const equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken); - const body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction); + const body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); const node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction: boolean): Expression | undefined { + function tryParseParenthesizedArrowFunctionExpression(): Expression | undefined { const triState = isParenthesizedArrowFunctionExpression(); if (triState === Tristate.False) { // It's definitely not a parenthesized arrow function expression. @@ -4462,8 +4464,8 @@ namespace ts { // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. return triState === Tristate.True ? - parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) : - tryParse(() => parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction)); + parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) : + tryParse(parsePossibleParenthesizedArrowFunctionExpression); } // True -> We definitely expect a parenthesized arrow function here. @@ -4609,13 +4611,13 @@ namespace ts { } } - function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction: boolean): ArrowFunction | undefined { + function parsePossibleParenthesizedArrowFunctionExpression(): ArrowFunction | undefined { const tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow?.has(tokenPos)) { return undefined; } - const result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction); + const result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new Set())).add(tokenPos); } @@ -4623,14 +4625,14 @@ namespace ts { return result; } - function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction: boolean): ArrowFunction | undefined { + function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" if (token() === SyntaxKind.AsyncKeyword) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === Tristate.True) { const pos = getNodePos(); const asyncModifier = parseModifiersForArrowFunction(); const expr = parseBinaryExpressionOrHigher(OperatorPrecedence.Lowest); - return parseSimpleArrowFunctionExpression(pos, expr as Identifier, disallowReturnTypeInArrowFunction, asyncModifier); + return parseSimpleArrowFunctionExpression(pos, expr as Identifier, asyncModifier); } } return undefined; @@ -4657,7 +4659,7 @@ namespace ts { return Tristate.False; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity: boolean, disallowReturnTypeInArrowFunction: boolean): ArrowFunction | undefined { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity: boolean): ArrowFunction | undefined { const pos = getNodePos(); const hasJSDoc = hasPrecedingJSDocComment(); const modifiers = parseModifiersForArrowFunction(); @@ -4694,24 +4696,6 @@ namespace ts { } } - // Given: - // x ? y => ({ y }) : z => ({ z }) - // We try to parse the body of the first arrow function by looking at: - // ({ y }) : z => ({ z }) - // This is a valid arrow function with "z" as the return type. - // - // But, if we're in the true side of a conditional expression, this colon - // terminates the expression, so we cannot allow a return type if we aren't - // certain whether or not the preceding text was parsed as a parameter list. - // - // For example, - // a() ? (b: number, c?: string): void => d() : e - // is determined by isParenthesizedArrowFunctionExpression to unambiguously - // be an arrow expression, so we allow a return type. - if (disallowReturnTypeInArrowFunction && token() === SyntaxKind.ColonToken) { - return undefined; - } - const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; @@ -4744,14 +4728,14 @@ namespace ts { const lastToken = token(); const equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken); const body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) - ? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier), disallowReturnTypeInArrowFunction) + ? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier)) : parseIdentifier(); const node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync: boolean, disallowReturnTypeInArrowFunction: boolean): Block | Expression { + function parseArrowFunctionExpressionBody(isAsync: boolean): Block | Expression { if (token() === SyntaxKind.OpenBraceToken) { return parseFunctionBlock(isAsync ? SignatureFlags.Await : SignatureFlags.None); } @@ -4781,8 +4765,8 @@ namespace ts { const savedTopLevel = topLevel; topLevel = false; const node = isAsync - ? doInAwaitContext(() => parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction)) - : doOutsideOfAwaitContext(() => parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction)); + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); topLevel = savedTopLevel; return node; } @@ -4801,10 +4785,10 @@ namespace ts { factory.createConditionalExpression( leftOperand, questionToken, - doOutsideOfContext(disallowInAndDecoratorContext, () => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true)), + doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(SyntaxKind.ColonToken), nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true) + ? parseAssignmentExpressionOrHigher() : createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken)) ), pos @@ -5735,34 +5719,10 @@ namespace ts { case SyntaxKind.OpenParenToken: // foo( case SyntaxKind.NoSubstitutionTemplateLiteral: // foo `...` case SyntaxKind.TemplateHead: // foo `...${100}...` - // These tokens can't follow in a call expression, nor can they start an - // expression. So, consider the type argument list part of an instantiation - // expression. - // falls through - case SyntaxKind.CommaToken: // foo, - case SyntaxKind.DotToken: // foo. - case SyntaxKind.QuestionDotToken: // foo?. - case SyntaxKind.CloseParenToken: // foo) - case SyntaxKind.CloseBracketToken: // foo] - case SyntaxKind.ColonToken: // foo: - case SyntaxKind.SemicolonToken: // foo; - case SyntaxKind.QuestionToken: // foo? - case SyntaxKind.EqualsEqualsToken: // foo == - case SyntaxKind.EqualsEqualsEqualsToken: // foo === - case SyntaxKind.ExclamationEqualsToken: // foo != - case SyntaxKind.ExclamationEqualsEqualsToken: // foo !== - case SyntaxKind.AmpersandAmpersandToken: // foo && - case SyntaxKind.BarBarToken: // foo || - case SyntaxKind.QuestionQuestionToken: // foo ?? - case SyntaxKind.CaretToken: // foo ^ - case SyntaxKind.AmpersandToken: // foo & - case SyntaxKind.BarToken: // foo | - case SyntaxKind.CloseBraceToken: // foo } - case SyntaxKind.EndOfFileToken: // foo return true; } - // Treat anything else as an expression. - return false; + // Consider something a type argument list only if the following token can't start an expression. + return !isStartOfExpression(); } function parsePrimaryExpression(): PrimaryExpression { @@ -5826,14 +5786,14 @@ namespace ts { function parseSpreadElement(): Expression { const pos = getNodePos(); parseExpected(SyntaxKind.DotDotDotToken); - const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + const expression = parseAssignmentExpressionOrHigher(); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement(): Expression { return token() === SyntaxKind.DotDotDotToken ? parseSpreadElement() : token() === SyntaxKind.CommaToken ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + parseAssignmentExpressionOrHigher(); } function parseArgumentExpression(): Expression { @@ -5855,7 +5815,7 @@ namespace ts { const hasJSDoc = hasPrecedingJSDocComment(); if (parseOptionalToken(SyntaxKind.DotDotDotToken)) { - const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + const expression = parseAssignmentExpressionOrHigher(); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } @@ -5890,7 +5850,7 @@ namespace ts { const isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== SyntaxKind.ColonToken); if (isShorthandPropertyAssignment) { const equalsToken = parseOptionalToken(SyntaxKind.EqualsToken); - const objectAssignmentInitializer = equalsToken ? allowInAnd(() => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)) : undefined; + const objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name as Identifier, objectAssignmentInitializer); // Save equals token for error reporting. // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful. @@ -5898,7 +5858,7 @@ namespace ts { } else { parseExpected(SyntaxKind.ColonToken); - const initializer = allowInAnd(() => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)); + const initializer = allowInAnd(parseAssignmentExpressionOrHigher); node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker @@ -6098,7 +6058,7 @@ namespace ts { let node: IterationStatement; if (awaitToken ? parseExpected(SyntaxKind.OfKeyword) : parseOptional(SyntaxKind.OfKeyword)) { - const expression = allowInAnd(() => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)); + const expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(SyntaxKind.CloseParenToken); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } @@ -7440,7 +7400,7 @@ namespace ts { const pos = getNodePos(); const name = tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(SyntaxKind.StringLiteral) as StringLiteral; parseExpected(SyntaxKind.ColonToken); - const value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + const value = parseAssignmentExpressionOrHigher(); return finishNode(factory.createAssertEntry(name, value), pos); } @@ -7511,7 +7471,7 @@ namespace ts { function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { @@ -7706,7 +7666,7 @@ namespace ts { else { parseExpected(SyntaxKind.DefaultKeyword); } - const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); + const expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); setAwaitContext(savedAwaitContext); const node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); @@ -7784,7 +7744,7 @@ namespace ts { const pos = getNodePos(); const hasBrace = parseOptional(SyntaxKind.OpenBraceToken); const p2 = getNodePos(); - let entityName: EntityName | JSDocMemberName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false); + let entityName: EntityName | JSDocMemberName = parseEntityName(/* allowReservedWords*/ false); while (token() === SyntaxKind.PrivateIdentifier) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # @@ -8247,7 +8207,7 @@ namespace ts { // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error const p2 = getNodePos(); let name: EntityName | JSDocMemberName | undefined = tokenIsIdentifierOrKeyword(token()) - ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false) + ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { while (token() === SyntaxKind.PrivateIdentifier) { @@ -8602,7 +8562,8 @@ namespace ts { if (!comment) { comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); + const end = comment !== undefined ? getNodePos() : typeExpression.end; + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); } function escapedTextsEqual(a: EntityName, b: EntityName): boolean { @@ -9413,7 +9374,7 @@ namespace ts { /** @internal */ export function isDeclarationFileName(fileName: string): boolean { - return fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Dmts, Extension.Dcts]); + return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions); } /*@internal*/ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 021c34ce3a7d6..7044953fee6be 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -262,7 +262,7 @@ namespace ts { return newValue; }; if (originalWriteFile) { - host.writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => { + host.writeFile = (fileName, data, ...rest) => { const key = toPath(fileName); fileExistsCache.delete(key); @@ -277,7 +277,7 @@ namespace ts { sourceFileCache.delete(key); } } - originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles); + originalWriteFile.call(host, fileName, data, ...rest); }; } @@ -593,7 +593,7 @@ namespace ts { } /* @internal */ - export function getResolutionModeOverrideForClause(clause: AssertClause | undefined, grammarErrorOnNode?: (node: Node, diagnostic: DiagnosticMessage) => boolean) { + export function getResolutionModeOverrideForClause(clause: AssertClause | undefined, grammarErrorOnNode?: (node: Node, diagnostic: DiagnosticMessage) => void) { if (!clause) return undefined; if (length(clause.elements) !== 1) { grammarErrorOnNode?.(clause, Diagnostics.Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require); @@ -858,7 +858,7 @@ namespace ts { */ export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined { switch (getEmitModuleResolutionKind(options)) { - case ModuleResolutionKind.Node12: + case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext : fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS : @@ -913,7 +913,6 @@ namespace ts { Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, - Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, @@ -1186,7 +1185,7 @@ namespace ts { else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) { const getCommonSourceDirectory = memoize(() => getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames())); for (const fileName of parsedRef.commandLine.fileNames) { - if (!fileExtensionIs(fileName, Extension.Dts) && !fileExtensionIs(fileName, Extension.Json)) { + if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, Extension.Json)) { processProjectReferenceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory), { kind: FileIncludeKind.OutputFromProjectReference, index }); } } @@ -1210,7 +1209,7 @@ namespace ts { const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (let i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: resolutions[i]?.packageId }); } tracing?.pop(); @@ -1340,6 +1339,7 @@ namespace ts { useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(), getFileIncludeReasons: () => fileReasons, structureIsReused, + writeFile, }; onProgramCreateComplete(); @@ -1364,6 +1364,36 @@ namespace ts { return program; + function addResolutionDiagnostics(list: Diagnostic[] | undefined) { + if (!list) return; + for (const elem of list) { + programDiagnostics.add(elem); + } + } + + function pullDiagnosticsFromCache(names: string[] | readonly FileReference[], containingFile: SourceFile) { + if (!moduleResolutionCache) return; + const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + const containingFileMode = !isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + const containingDir = getDirectoryPath(containingFileName); + const redirectedReference = getRedirectReferenceForResolution(containingFile); + let i = 0; + for (const n of names) { + // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less + const mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode); + const name = typeof n === "string" ? n : n.fileName; + i++; + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + if (isExternalModuleNameRelative(name)) continue; + const diags = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)?.resolutionDiagnostics; + addResolutionDiagnostics(diags); + } + } + function resolveModuleNamesWorker(moduleNames: string[], containingFile: SourceFile, reusedNames: string[] | undefined): readonly ResolvedModuleFull[] { if (!moduleNames.length) return emptyArray; const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); @@ -1374,6 +1404,7 @@ namespace ts { performance.mark("afterResolveModule"); performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); tracing?.pop(); + pullDiagnosticsFromCache(moduleNames, containingFile); return result; } @@ -1393,7 +1424,7 @@ namespace ts { function getRedirectReferenceForResolution(file: SourceFile) { const redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !fileExtensionIsOneOf(file.originalFileName, [Extension.Dts, Extension.Dcts, Extension.Dmts])) return redirect; + if (redirect || !isDeclarationFileName(file.originalFileName)) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case @@ -1894,8 +1925,7 @@ namespace ts { getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect, getSymlinkCache, - writeFile: writeFileCallback || ( - (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), + writeFile: writeFileCallback || writeFile, isEmitBlocked, readFile: f => host.readFile(f), fileExists: f => { @@ -1914,6 +1944,17 @@ namespace ts { }; } + function writeFile( + fileName: string, + text: string, + writeByteOrderMark: boolean, + onError?: (message: string) => void, + sourceFiles?: readonly SourceFile[], + data?: WriteFileCallbackData + ) { + host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data); + } + function emitBuildInfo(writeFileCallback?: WriteFileCallback): EmitResult { Debug.assert(!outFile(options)); tracing?.push(tracing.Phase.Emit, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); @@ -2969,7 +3010,7 @@ namespace ts { function getProjectReferenceRedirectProject(fileName: string) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts) || fileExtensionIs(fileName, Extension.Json)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || isDeclarationFileName(fileName) || fileExtensionIs(fileName, Extension.Json)) { return undefined; } @@ -3025,7 +3066,7 @@ namespace ts { else { const getCommonSourceDirectory = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames())); forEach(resolvedRef.commandLine.fileNames, fileName => { - if (!fileExtensionIs(fileName, Extension.Dts) && !fileExtensionIs(fileName, Extension.Json)) { + if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, Extension.Json)) { const outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory); mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), fileName); } @@ -3074,8 +3115,8 @@ namespace ts { const fileName = toFileNameLowerCase(ref.fileName); setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); const mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { - programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { + programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: FileIncludeKind.TypeReferenceDirective, file: file.path, index, }); } @@ -3504,7 +3545,7 @@ namespace ts { if (options.resolveJsonModule) { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && - getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node12 && + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } @@ -3947,7 +3988,7 @@ namespace ts { return containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (fileExtensionIsOneOf(filePath, supportedJSExtensionsFlat) || fileExtensionIs(filePath, Extension.Dts)) { + if (fileExtensionIsOneOf(filePath, supportedJSExtensionsFlat) || isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists const filePathWithoutExtension = removeFileExtension(filePath); return !!getSourceFileByPath((filePathWithoutExtension + Extension.Ts) as Path) || diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 48ac670c8bea3..6cdcc6a26b9e4 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1210,11 +1210,13 @@ namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; /*@internal*/ bufferFrom?(input: string, encoding?: string): Buffer; + /*@internal*/ require?(baseDir: string, moduleName: string): RequireResult; + /*@internal*/ defaultWatchFileKind?(): WatchFileKind | undefined; + // For testing /*@internal*/ now?(): Date; /*@internal*/ disableUseFileVersionAsSignature?: boolean; - /*@internal*/ require?(baseDir: string, moduleName: string): RequireResult; - /*@internal*/ defaultWatchFileKind?(): WatchFileKind | undefined; + /*@internal*/ storeFilesChangingSignatureDuringEmit?: boolean; } export interface FileWatcher { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 7207d8a60d75b..bfe7017150406 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -9,7 +9,7 @@ namespace ts { return transformECMAScriptModule; case ModuleKind.System: return transformSystemModule; - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return transformNodeModule; default: diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 3ac842e8abab5..cff2be7fb78b8 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -1294,7 +1294,7 @@ namespace ts { resumeLexicalEnvironment(); const needsSyntheticConstructor = !constructor && isDerivedClass; - let indexOfFirstStatementAfterSuper = 0; + let indexOfFirstStatementAfterSuperAndPrologue = 0; let prologueStatementCount = 0; let superStatementIndex = -1; let statements: Statement[] = []; @@ -1305,13 +1305,16 @@ namespace ts { // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuper = superStatementIndex + 1; + indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; statements = [ ...statements.slice(0, prologueStatementCount), - ...visitNodes(constructor.body.statements, visitor, isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), + ...visitNodes(constructor.body.statements, visitor, isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), ...statements.slice(prologueStatementCount), ]; } + else if (prologueStatementCount >= 0) { + indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; + } } if (needsSyntheticConstructor) { @@ -1354,26 +1357,25 @@ namespace ts { } } if (parameterPropertyDeclarationCount > 0) { - const parameterProperties = visitNodes(constructor.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount); + const parameterProperties = visitNodes(constructor.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount); // If there was a super() call found, add parameter properties immediately after it if (superStatementIndex >= 0) { addRange(statements, parameterProperties); } - // If a synthetic super() call was added, add them just after it - else if (needsSyntheticConstructor) { + else { + // Add add parameter properties to the top of the constructor after the prologue + let superAndPrologueStatementCount = prologueStatementCount; + // If a synthetic super() call was added, need to account for that + if (needsSyntheticConstructor) superAndPrologueStatementCount++; statements = [ - statements[0], + ...statements.slice(0, superAndPrologueStatementCount), ...parameterProperties, - ...statements.slice(1), + ...statements.slice(superAndPrologueStatementCount), ]; } - // Since there wasn't a super() call, add them to the top of the constructor - else { - statements = [...parameterProperties, ...statements]; - } - indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount; + indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; } } } @@ -1385,7 +1387,7 @@ namespace ts { // Add existing statements after the initial prologues and super call if (constructor) { - addRange(statements, visitNodes(constructor.body!.statements, visitBodyStatement, isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount)); + addRange(statements, visitNodes(constructor.body!.statements, visitBodyStatement, isStatement, indexOfFirstStatementAfterSuperAndPrologue)); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index bfbd4d4471259..b855fd4b8dab5 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -733,7 +733,7 @@ namespace ts { decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), - getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined + getResolutionModeOverrideForClauseInNightly(decl.assertClause) ); } // The `importClause` visibility corresponds to the default's visibility. @@ -745,7 +745,7 @@ namespace ts { decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined, - ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined); + ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } if (decl.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { // Namespace import (optionally with visible default) @@ -755,7 +755,7 @@ namespace ts { decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings, - ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined; + ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } // Named imports (optionally with visible default) const bindingList = mapDefined(decl.importClause.namedBindings.elements, b => resolver.isDeclarationVisible(b) ? b : undefined); @@ -771,7 +771,7 @@ namespace ts { bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined, ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), - getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined + getResolutionModeOverrideForClauseInNightly(decl.assertClause) ); } // Augmentation of export depends on import @@ -782,12 +782,23 @@ namespace ts { decl.modifiers, /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), - getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined + getResolutionModeOverrideForClauseInNightly(decl.assertClause) ); } // Nothing visible } + function getResolutionModeOverrideForClauseInNightly(assertClause: AssertClause | undefined) { + const mode = getResolutionModeOverrideForClause(assertClause); + if (mode !== undefined) { + if (!isNightly()) { + context.addDiagnostic(createDiagnosticForNode(assertClause!, Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next)); + } + return assertClause; + } + return undefined; + } + function transformAndReplaceLatePaintedStatements(statements: NodeArray): NodeArray { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. @@ -1140,6 +1151,9 @@ namespace ts { const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const)); + + preserveJsDoc(statement, input); + removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -1163,6 +1177,9 @@ namespace ts { } function transformTopLevelDeclaration(input: LateVisibilityPaintedStatement) { + if (lateMarkedStatements) { + while (orderedRemoveItem(lateMarkedStatements, input)); + } if (shouldStripInternal(input)) return; switch (input.kind) { case SyntaxKind.ImportEqualsDeclaration: { diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 36a0f29d109e3..38ad28faacc32 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -1146,7 +1146,7 @@ namespace ts { [ ...existingPrologue, ...prologue, - ...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex)), + ...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), ...statements ] ), diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 994601a426563..bcb92d9594a8a 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1938,14 +1938,14 @@ namespace ts { resumeLexicalEnvironment(); - const indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - const superStatementIndex = findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement); + const prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); + const superStatementIndex = findSuperStatementIndex(body.statements, prologueStatementCount); // If there was a super call, visit existing statements up to and including it if (superStatementIndex >= 0) { addRange( statements, - visitNodes(body.statements, visitor, isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement), + visitNodes(body.statements, visitor, isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount), ); } @@ -1967,13 +1967,17 @@ namespace ts { if (superStatementIndex >= 0) { addRange(statements, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor + // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = addRange(parameterPropertyAssignments, statements); + statements = [ + ...statements.slice(0, prologueStatementCount), + ...parameterPropertyAssignments, + ...statements.slice(prologueStatementCount), + ]; } - // Add remaining statements from the body, skipping the super() call if it was found - addRange(statements, visitNodes(body.statements, visitor, isStatement, superStatementIndex + 1)); + // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements + addRange(statements, visitNodes(body.statements, visitor, isStatement, superStatementIndex + 1 + prologueStatementCount)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index ad9f97f2dd8ab..280ebfcd2679b 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -72,10 +72,6 @@ namespace ts { return date2 > date1 ? date2 : date1; } - function isDeclarationFile(fileName: string) { - return fileExtensionIs(fileName, Extension.Dts); - } - export type ReportEmitErrorSummary = (errorCount: number, filesInError: (ReportFileInError | undefined)[]) => void; export interface ReportFileInError { @@ -972,7 +968,7 @@ namespace ts { const emittedOutputs = new Map(); outputFiles.forEach(({ name, text, writeByteOrderMark }) => { let priorChangeTime: Date | undefined; - if (!anyDtsChanged && isDeclarationFile(name)) { + if (!anyDtsChanged && isDeclarationFileName(name)) { // Check for unchanged .d.ts files if (host.fileExists(name) && state.readFileWithCache(name) === text) { priorChangeTime = host.getModifiedTime(name); @@ -1421,7 +1417,7 @@ namespace ts { // In addition to file timestamps, we also keep track of when a .d.ts file // had its file touched but not had its contents changed - this allows us // to skip a downstream typecheck - if (isDeclarationFile(output)) { + if (isDeclarationFileName(output)) { const outputModifiedTime = getModifiedTime(host, output); newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } @@ -1589,7 +1585,7 @@ namespace ts { reportStatus(state, verboseMessage, proj.options.configFilePath!); } - if (isDeclarationFile(file)) { + if (isDeclarationFileName(file)) { priorNewestUpdateTime = newer(priorNewestUpdateTime, getModifiedTime(host, file)); } @@ -1900,7 +1896,7 @@ namespace ts { { createNewValue: (path, _input) => state.watchFile( path, - () => invalidateProjectAndScheduleBuilds(state, resolvedPath, ConfigFileProgramReloadLevel.Full), + () => invalidateProjectAndScheduleBuilds(state, resolvedPath, ConfigFileProgramReloadLevel.None), PollingInterval.High, parsed?.watchOptions, WatchType.PackageJson, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2302c95322fc7..6becb6813eac6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3615,7 +3615,7 @@ namespace ts { languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -3856,12 +3856,16 @@ namespace ts { */ export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never }; + export interface WriteFileCallbackData { + /*@internal*/ sourceMapUrlPos?: number; + } export type WriteFileCallback = ( fileName: string, - data: string, + text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], + data?: WriteFileCallbackData, ) => void; export class OperationCanceledException { } @@ -4067,6 +4071,8 @@ namespace ts { * This implementation handles file exists to be true if file is source of project reference redirect when program is created using useSourceOfProjectReferenceRedirect */ /*@internal*/ fileExists(fileName: string): boolean; + /** Call compilerHost.writeFile on host program was created with */ + /*@internal*/ writeFile: WriteFileCallback; } /*@internal*/ @@ -4490,7 +4496,6 @@ namespace ts { UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type NoTypeReduction = 1 << 29, // Don't call getReducedType - NoUndefinedOptionalParameterType = 1 << 30, // Do not add undefined to optional parameter type // Error handling AllowThisInObjectLiteral = 1 << 15, @@ -4669,8 +4674,10 @@ namespace ts { export type AnyImportOrRequire = AnyImportSyntax | VariableDeclarationInitializedTo; /* @internal */ - export type AnyImportOrRequireStatement = AnyImportSyntax | RequireVariableStatement; + export type AnyImportOrBareOrAccessedRequire = AnyImportSyntax | VariableDeclarationInitializedTo; + /* @internal */ + export type AnyImportOrRequireStatement = AnyImportSyntax | RequireVariableStatement; /* @internal */ export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration; @@ -4943,7 +4950,8 @@ namespace ts { /* @internal */ export interface SymbolLinks { immediateTarget?: Symbol; // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead. - target?: Symbol; // Resolved (non-alias) target of an alias + aliasTarget?: Symbol, // Resolved (non-alias) target of an alias + target?: Symbol; // Original version of an instantiated symbol type?: Type; // Type of value symbol writeType?: Type; // Type of value symbol in write contexts nameType?: Type; // Type associated with a late-bound symbol @@ -6041,11 +6049,12 @@ namespace ts { Classic = 1, NodeJs = 2, // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - Node12 = 3, - NodeNext = 99, // Not simply `Node12` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + Node16 = 3, + NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) } export enum ModuleDetectionKind { @@ -6054,7 +6063,7 @@ namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -6178,6 +6187,8 @@ namespace ts { assumeChangesOnlyAffectDirectDependencies?: boolean; noLib?: boolean; noResolve?: boolean; + /*@internal*/ + noDtsResolution?: boolean; noUncheckedIndexedAccess?: boolean; out?: string; outDir?: string; @@ -6271,8 +6282,8 @@ namespace ts { ES2022 = 7, ESNext = 99, - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - Node12 = 100, + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + Node16 = 100, NodeNext = 199, } @@ -6706,6 +6717,8 @@ namespace ts { readonly resolvedModule: ResolvedModuleFull | undefined; /* @internal */ readonly failedLookupLocations: string[]; + /* @internal */ + readonly resolutionDiagnostics: Diagnostic[] } export interface ResolvedTypeReferenceDirective { @@ -6727,6 +6740,8 @@ namespace ts { export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; readonly failedLookupLocations: string[]; + /* @internal */ + resolutionDiagnostics: Diagnostic[] } /* @internal */ @@ -6778,6 +6793,7 @@ namespace ts { // For testing: /*@internal*/ disableUseFileVersionAsSignature?: boolean; + /*@internal*/ storeFilesChangingSignatureDuringEmit?: boolean; } /** true if --out otherwise source file name */ @@ -8459,7 +8475,7 @@ namespace ts { export interface ResolvedModuleSpecifierInfo { modulePaths: readonly ModulePath[] | undefined; moduleSpecifiers: readonly string[] | undefined; - isAutoImportable: boolean | undefined; + isBlockedByPackageJsonDependencies: boolean | undefined; } /* @internal */ @@ -8471,7 +8487,7 @@ namespace ts { export interface ModuleSpecifierCache { get(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions): Readonly | undefined; set(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, modulePaths: readonly ModulePath[], moduleSpecifiers: readonly string[]): void; - setIsAutoImportable(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, isAutoImportable: boolean): void; + setBlockedByPackageJsonDependencies(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, isBlockedByPackageJsonDependencies: boolean): void; setModulePaths(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, modulePaths: readonly ModulePath[]): void; clear(): void; count(): number; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3b303c65eb83f..6036f516bb025 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -656,10 +656,10 @@ namespace ts { AllowNumericSeparator = 1 << 3 } - export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, flags: GetLiteralTextFlags) { + export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile | undefined, flags: GetLiteralTextFlags) { // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (canUseOriginalText(node, flags)) { + if (sourceFile && canUseOriginalText(node, flags)) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } @@ -808,7 +808,7 @@ namespace ts { } function isCommonJSContainingModuleKind(kind: ModuleKind) { - return kind === ModuleKind.CommonJS || kind === ModuleKind.Node12 || kind === ModuleKind.NodeNext; + return kind === ModuleKind.CommonJS || kind === ModuleKind.Node16 || kind === ModuleKind.NodeNext; } export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) { @@ -933,6 +933,10 @@ namespace ts { } } + export function isAnyImportOrBareOrAccessedRequire(node: Node): node is AnyImportOrBareOrAccessedRequire { + return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node); + } + export function isLateVisibilityPaintedStatement(node: Node): node is LateVisibilityPaintedStatement { switch (node.kind) { case SyntaxKind.ImportDeclaration: @@ -2338,18 +2342,13 @@ namespace ts { if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } - if (isIdentifier(name) && isLiteralLikeAccess(initializer) && + if (isMemberName(name) && isLiteralLikeAccess(initializer) && (initializer.expression.kind === SyntaxKind.ThisKeyword || isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) { - - const nameOrArgument = getNameOrArgument(initializer); - if (isPrivateIdentifier(nameOrArgument)) { - Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access."); - } - return isSameEntityName(name, nameOrArgument); + return isSameEntityName(name, getNameOrArgument(initializer)); } if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) @@ -2563,14 +2562,14 @@ namespace ts { return decl.kind === SyntaxKind.FunctionDeclaration || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer); } - export function tryGetModuleSpecifierFromDeclaration(node: AnyImportOrRequire): string | undefined { + export function tryGetModuleSpecifierFromDeclaration(node: AnyImportOrBareOrAccessedRequire): StringLiteralLike | undefined { switch (node.kind) { case SyntaxKind.VariableDeclaration: - return node.initializer.arguments[0].text; + return findAncestor(node.initializer, (node): node is RequireOrImportCall => isRequireCall(node, /*requireStringLiteralLikeArgument*/ true))?.arguments[0]; case SyntaxKind.ImportDeclaration: - return tryCast(node.moduleSpecifier, isStringLiteralLike)?.text; + return tryCast(node.moduleSpecifier, isStringLiteralLike); case SyntaxKind.ImportEqualsDeclaration: - return tryCast(tryCast(node.moduleReference, isExternalModuleReference)?.expression, isStringLiteralLike)?.text; + return tryCast(tryCast(node.moduleReference, isExternalModuleReference)?.expression, isStringLiteralLike); default: Debug.assertNever(node); } @@ -3117,7 +3116,10 @@ namespace ts { return (parent as BindingElement | ImportSpecifier).propertyName === node; case SyntaxKind.ExportSpecifier: case SyntaxKind.JsxAttribute: - // Any name in an export specifier or JSX Attribute + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxClosingElement: + // Any name in an export specifier or JSX Attribute or Jsx Element return true; } return false; @@ -3133,21 +3135,31 @@ namespace ts { // export = // export default // module.exports = - // {} - // {name: } + // module.exports.x = + // const x = require("...") + // const { x } = require("...") + // const x = require("...").y + // const { x } = require("...").y export function isAliasSymbolDeclaration(node: Node): boolean { - return node.kind === SyntaxKind.ImportEqualsDeclaration || + if (node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.NamespaceExportDeclaration || node.kind === SyntaxKind.ImportClause && !!(node as ImportClause).name || node.kind === SyntaxKind.NamespaceImport || node.kind === SyntaxKind.NamespaceExport || node.kind === SyntaxKind.ImportSpecifier || node.kind === SyntaxKind.ExportSpecifier || - node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node as ExportAssignment) || + node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node as ExportAssignment) + ) { + return true; + } + + return isInJSFile(node) && ( isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) || - isPropertyAccessExpression(node) && isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === SyntaxKind.EqualsToken && isAliasableExpression(node.parent.right) || - node.kind === SyntaxKind.ShorthandPropertyAssignment || - node.kind === SyntaxKind.PropertyAssignment && isAliasableExpression((node as PropertyAssignment).initializer); + isPropertyAccessExpression(node) + && isBinaryExpression(node.parent) + && node.parent.left === node + && node.parent.operatorToken.kind === SyntaxKind.EqualsToken + && isAliasableExpression(node.parent.right)); } export function getAliasDeclarationFromName(node: EntityName): Declaration | undefined { @@ -3158,6 +3170,7 @@ namespace ts { case SyntaxKind.ExportSpecifier: case SyntaxKind.ExportAssignment: case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.NamespaceExport: return node.parent as Declaration; case SyntaxKind.QualifiedName: do { @@ -4108,6 +4121,10 @@ namespace ts { return indentStrings[1].length; } + export function isNightly() { + return stringContains(version, "-dev") || stringContains(version, "-insiders"); + } + export function createTextWriter(newLine: string): EmitTextWriter { let output: string; let indent: number; @@ -4374,6 +4391,16 @@ namespace ts { Extension.Dts; } + /** + * This function is an inverse of `getDeclarationEmitExtensionForPath`. + */ + export function getPossibleOriginalInputExtensionForExtension(path: string) { + return fileExtensionIsOneOf(path, [Extension.Dmts, Extension.Mjs, Extension.Mts]) ? [Extension.Mts, Extension.Mjs] : + fileExtensionIsOneOf(path, [Extension.Dcts, Extension.Cjs, Extension.Cts]) ? [Extension.Cts, Extension.Cjs]: + fileExtensionIsOneOf(path, [`.json.d.ts`]) ? [Extension.Json] : + [Extension.Tsx, Extension.Ts, Extension.Jsx, Extension.Js]; + } + export function outFile(options: CompilerOptions) { return options.outFile || options.out; } @@ -4446,10 +4473,10 @@ namespace ts { return combinePaths(newDirPath, sourceFilePath); } - export function writeFile(host: { writeFile: WriteFileCallback; }, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: readonly SourceFile[]) { - host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => { + export function writeFile(host: { writeFile: WriteFileCallback; }, diagnostics: DiagnosticCollection, fileName: string, text: string, writeByteOrderMark: boolean, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) { + host.writeFile(fileName, text, writeByteOrderMark, hostErrorMessage => { diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); + }, sourceFiles, data); } function ensureDirectoriesExist( @@ -5144,6 +5171,11 @@ namespace ts { (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent as PropertyAccessExpression).name === node); } + export function isRightSideOfAccessExpression(node: Node) { + return isPropertyAccessExpression(node.parent) && node.parent.name === node + || isElementAccessExpression(node.parent) && node.parent.argumentExpression === node; + } + export function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node: Node) { return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node @@ -5831,6 +5863,45 @@ namespace ts { return expr; } + export function forEachNameInAccessChainWalkingLeft(name: MemberName | StringLiteralLike, action: (name: MemberName | StringLiteralLike) => T | undefined): T | undefined { + if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) { + return walkAccessExpression(name.parent); + } + + function walkAccessExpression(access: AccessExpression): T | undefined { + if (access.kind === SyntaxKind.PropertyAccessExpression) { + const res = action(access.name); + if (res !== undefined) { + return res; + } + } + else if (access.kind === SyntaxKind.ElementAccessExpression) { + if (isIdentifier(access.argumentExpression) || isStringLiteralLike(access.argumentExpression)) { + const res = action(access.argumentExpression); + if (res !== undefined) { + return res; + } + } + else { + // Chain interrupted by non-static-name access 'x[expr()].y.z' + return undefined; + } + } + + if (isAccessExpression(access.expression)) { + return walkAccessExpression(access.expression); + } + if (isIdentifier(access.expression)) { + // End of chain at Identifier 'x.y.z' + return action(access.expression); + } + // End of chain at non-Identifier 'x().y.z' + return undefined; + } + } + + + export function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) { while (true) { switch (node.kind) { @@ -6262,7 +6333,7 @@ namespace ts { file.externalModuleIndicator = isFileProbablyExternalModule(file); }; case ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness const checks: ((file: SourceFile) => Node | true | undefined)[] = [isFileProbablyExternalModule]; @@ -6270,7 +6341,7 @@ namespace ts { checks.push(isFileModuleFromUsingJSXTag); } const moduleKind = getEmitModuleKind(options); - if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) { + if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } const combined = or(...checks); @@ -6281,7 +6352,7 @@ namespace ts { export function getEmitScriptTarget(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) { return compilerOptions.target || - (compilerOptions.module === ModuleKind.Node12 && ScriptTarget.ES2020) || + (compilerOptions.module === ModuleKind.Node16 && ScriptTarget.ES2022) || (compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) || ScriptTarget.ES3; } @@ -6299,8 +6370,8 @@ namespace ts { case ModuleKind.CommonJS: moduleResolution = ModuleResolutionKind.NodeJs; break; - case ModuleKind.Node12: - moduleResolution = ModuleResolutionKind.Node12; + case ModuleKind.Node16: + moduleResolution = ModuleResolutionKind.Node16; break; case ModuleKind.NodeNext: moduleResolution = ModuleResolutionKind.NodeNext; @@ -6325,7 +6396,7 @@ namespace ts { case ModuleKind.ES2020: case ModuleKind.ES2022: case ModuleKind.ESNext: - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return true; default: @@ -6350,7 +6421,7 @@ namespace ts { return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return true; } @@ -6918,6 +6989,7 @@ namespace ts { export const supportedJSExtensionsFlat: readonly Extension[] = flatten(supportedJSExtensions); const allSupportedExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Js, Extension.Jsx], [Extension.Cts, Extension.Dcts, Extension.Cjs], [Extension.Mts, Extension.Dmts, Extension.Mjs]]; const allSupportedExtensionsWithJson: readonly Extension[][] = [...allSupportedExtensions, [Extension.Json]]; + export const supportedDeclarationExtensions: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts]; export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[][]; export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][]; @@ -7659,4 +7731,8 @@ namespace ts { return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined; } + + export function getParameterTypeNode(parameter: ParameterDeclaration | JSDocParameterTag) { + return parameter.kind === SyntaxKind.JSDocParameterTag ? parameter.typeExpression?.type : parameter.type; + } } diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index b2f7a0a3bc540..6c422d31f0cd5 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -573,6 +573,7 @@ namespace ts { createHash: maybeBind(host, host.createHash), readDirectory: maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) { @@ -637,6 +638,7 @@ namespace ts { createHash: maybeBind(system, system.createHash), createProgram: createProgram || createEmitAndSemanticDiagnosticsBuilderProgram as any as CreateProgram, disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, + storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit, }; } diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index 095c0f69a1083..8af1397e19cff 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -20,6 +20,7 @@ namespace ts { const host = createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; + host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; setGetSourceFileAsHashVersioned(host, system); changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName)); return host; @@ -114,6 +115,7 @@ namespace ts { writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void; // For testing disableUseFileVersionAsSignature?: boolean; + storeFilesChangingSignatureDuringEmit?: boolean; } export interface WatchCompilerHost extends ProgramHost, WatchHost { diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index adbf9f1287b1b..e2fba1da6575d 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -495,7 +495,7 @@ namespace ts { if (outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored - if (fileExtensionIs(fileOrDirectoryPath, Extension.Dts)) { + if (isDeclarationFileName(fileOrDirectoryPath)) { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; } diff --git a/src/deprecatedCompat/deprecations.ts b/src/deprecatedCompat/deprecations.ts index 292840166b36f..98c47085f234d 100644 --- a/src/deprecatedCompat/deprecations.ts +++ b/src/deprecatedCompat/deprecations.ts @@ -1092,7 +1092,7 @@ namespace ts { } return factory.createYieldExpression(asteriskToken, expression); } as { - (expression?: Expression): YieldExpression; + (expression?: Expression | undefined): YieldExpression; (asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; }, factoryDeprecation); @@ -1125,7 +1125,7 @@ namespace ts { name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, - initializer?: Expression + initializer?: Expression | undefined ): PropertySignature { const node = factory.createPropertySignature(modifiers, name, questionToken, type); node.initializer = initializer; @@ -1187,7 +1187,7 @@ namespace ts { arguments.length >= 1 && arguments.length <= 3 ? factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, exclamationTokenOrType as TypeNode | undefined, typeOrInitializer as Expression | undefined) : Debug.fail("Argument count mismatch"); } as { - (name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; + (name: string | BindingName, type?: TypeNode | undefined, initializer?: Expression | undefined): VariableDeclaration; (name: string | BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; }, factoryDeprecation); @@ -1212,7 +1212,7 @@ namespace ts { }, factoryDeprecation); /** @deprecated Use `factory.createExportDeclaration` or the factory supplied by your transformation context instead. */ - export const createExportDeclaration = Debug.deprecate(function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, isTypeOnly = false) { + export const createExportDeclaration = Debug.deprecate(function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression | undefined, isTypeOnly = false) { return factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier); }, factoryDeprecation); @@ -1228,7 +1228,7 @@ namespace ts { }, factoryDeprecation); /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - export const createJSDocParamTag = Debug.deprecate(function createJSDocParamTag(name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, comment?: string): JSDocParameterTag { + export const createJSDocParamTag = Debug.deprecate(function createJSDocParamTag(name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined): JSDocParameterTag { return factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? factory.createNodeArray([factory.createJSDocText(comment)]) : undefined); }, factoryDeprecation); diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index a7d776acd802f..68d2e51e9d4eb 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -649,7 +649,7 @@ namespace ts { return false; } - export type ExecuteCommandLineCallbacks = (program: Program | EmitAndSemanticDiagnosticsBuilderProgram | ParsedCommandLine) => void; + export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void; export function executeCommandLine( system: System, cb: ExecuteCommandLineCallbacks, diff --git a/src/harness/client.ts b/src/harness/client.ts index 296832388baf6..7c8869995bb05 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -38,6 +38,7 @@ namespace ts.server { private lineMaps = new Map(); private messages: string[] = []; private lastRenameEntry: RenameEntry | undefined; + private preferences: UserPreferences | undefined; constructor(private host: SessionClientHost) { } @@ -124,6 +125,7 @@ namespace ts.server { /*@internal*/ configure(preferences: UserPreferences) { + this.preferences = preferences; const args: protocol.ConfigureRequestArguments = { preferences }; const request = this.processRequest(CommandNames.Configure, args); this.processResponse(request, /*expectEmptyBody*/ true); @@ -298,7 +300,7 @@ namespace ts.server { getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan { const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position); - const request = this.processRequest(CommandNames.DefinitionAndBoundSpan, args); + const request = this.processRequest(CommandNames.DefinitionAndBoundSpan, args); const response = this.processResponse(request); const body = Debug.checkDefined(response.body); // TODO: GH#18217 @@ -332,6 +334,23 @@ namespace ts.server { })); } + getSourceDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfo[] { + const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position); + const request = this.processRequest(CommandNames.FindSourceDefinition, args); + const response = this.processResponse(request); + const body = Debug.checkDefined(response.body); // TODO: GH#18217 + + return body.map(entry => ({ + containerKind: ScriptElementKind.unknown, + containerName: "", + fileName: entry.file, + textSpan: this.decodeSpan(entry), + kind: ScriptElementKind.unknown, + name: "", + unverified: entry.unverified, + })); + } + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] { const args = this.createFileLocationRequestArgs(fileName, position); @@ -471,13 +490,25 @@ namespace ts.server { return notImplemented(); } - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] { + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): RenameLocation[] { if (!this.lastRenameEntry || this.lastRenameEntry.inputs.fileName !== fileName || this.lastRenameEntry.inputs.position !== position || this.lastRenameEntry.inputs.findInStrings !== findInStrings || this.lastRenameEntry.inputs.findInComments !== findInComments) { - this.getRenameInfo(fileName, position, { allowRenameOfImportPath: true }, findInStrings, findInComments); + if (providePrefixAndSuffixTextForRename !== undefined) { + // User preferences have to be set through the `Configure` command + this.configure({ providePrefixAndSuffixTextForRename }); + // Options argument is not used, so don't pass in options + this.getRenameInfo(fileName, position, /*options*/{}, findInStrings, findInComments); + // Restore previous user preferences + if (this.preferences) { + this.configure(this.preferences); + } + } + else { + this.getRenameInfo(fileName, position, /*options*/{}, findInStrings, findInComments); + } } return this.lastRenameEntry!.locations; diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts index 40e3994b1c9bd..999c9d4e2733c 100644 --- a/src/harness/compilerImpl.ts +++ b/src/harness/compilerImpl.ts @@ -249,7 +249,7 @@ namespace compiler { } // establish defaults (aligns with old harness) - if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node12 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3; + if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node16 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3; if (compilerOptions.newLine === undefined) compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; if (compilerOptions.skipDefaultLibCheck === undefined) compilerOptions.skipDefaultLibCheck = true; if (compilerOptions.noErrorTruncation === undefined) compilerOptions.noErrorTruncation = true; diff --git a/src/harness/fakesHosts.ts b/src/harness/fakesHosts.ts index 58b29a4c7ef98..b1fc0e69c6547 100644 --- a/src/harness/fakesHosts.ts +++ b/src/harness/fakesHosts.ts @@ -511,18 +511,19 @@ ${indentText}${text}`; buildInfo.version = ts.version; return ts.getBuildInfoText(buildInfo); }; + return patchHostForBuildInfoWrite(sys, version); + } + + export function patchHostForBuildInfoWrite(sys: T, version: string) { const originalWrite = sys.write; sys.write = msg => originalWrite.call(sys, msg.replace(ts.version, version)); - - if (sys.writeFile) { - const originalWriteFile = sys.writeFile; - sys.writeFile = (fileName: string, content: string, writeByteOrderMark: boolean) => { - if (!ts.isBuildInfoFile(fileName)) return originalWriteFile.call(sys, fileName, content, writeByteOrderMark); - const buildInfo = ts.getBuildInfo(content); - buildInfo.version = version; - originalWriteFile.call(sys, fileName, ts.getBuildInfoText(buildInfo), writeByteOrderMark); - }; - } + const originalWriteFile = sys.writeFile; + sys.writeFile = (fileName: string, content: string, writeByteOrderMark: boolean) => { + if (!ts.isBuildInfoFile(fileName)) return originalWriteFile.call(sys, fileName, content, writeByteOrderMark); + const buildInfo = ts.getBuildInfo(content); + buildInfo.version = version; + originalWriteFile.call(sys, fileName, ts.getBuildInfoText(buildInfo), writeByteOrderMark); + }; return sys; } diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index f4b2832c00b6e..d65aa86fb6b02 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -697,6 +697,13 @@ namespace FourSlash { this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan()); } + public verifyGoToSourceDefinition(startMarkerNames: ArrayOrSingle, end?: ArrayOrSingle | { file: string, unverified?: boolean }) { + if (this.testType !== FourSlashTestType.Server) { + this.raiseError("goToSourceDefinition may only be used in fourslash/server tests."); + } + this.verifyGoToX(startMarkerNames, end, () => (this.languageService as ts.server.SessionClient).getSourceDefinitionAndBoundSpan(this.activeFile.fileName, this.currentCaretPosition)!); + } + private getGoToDefinition(): readonly ts.DefinitionInfo[] { return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)!; } @@ -764,7 +771,9 @@ namespace FourSlash { } if (endMarkers.length !== definitions.length) { - this.raiseError(`${testName} failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`); + const markers = definitions.map(d => ({ text: "HERE", fileName: d.fileName, position: d.textSpan.start })); + const actual = this.renderMarkers(markers); + this.raiseError(`${testName} failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}\n\n${actual}`); } ts.zipWith(endMarkers, definitions, (endMarkerOrFileResult, definition, i) => { @@ -774,17 +783,8 @@ namespace FourSlash { ts.Debug.assert(typeof expectedFileName === "string"); const expectedPosition = marker?.position || 0; if (ts.comparePaths(expectedFileName, definition.fileName, /*ignoreCase*/ true) !== ts.Comparison.EqualTo || expectedPosition !== definition.textSpan.start) { - const filesToDisplay = ts.deduplicate([expectedFileName, definition.fileName], ts.equateValues); const markers = [{ text: "EXPECTED", fileName: expectedFileName, position: expectedPosition }, { text: "ACTUAL", fileName: definition.fileName, position: definition.textSpan.start }]; - const text = filesToDisplay.map(fileName => { - const markersToRender = markers.filter(m => m.fileName === fileName).sort((a, b) => b.position - a.position); - let fileContent = this.tryGetFileContent(fileName) || ""; - for (const marker of markersToRender) { - fileContent = fileContent.slice(0, marker.position) + `\x1b[1;4m/*${marker.text}*/\x1b[0;31m` + fileContent.slice(marker.position); - } - return `// @Filename: ${fileName}\n${fileContent}`; - }).join("\n\n"); - + const text = this.renderMarkers(markers); this.raiseError(`${testName} failed for definition ${markerName || expectedFileName} (${i}): expected ${expectedFileName} at ${expectedPosition}, got ${definition.fileName} at ${definition.textSpan.start}\n\n${text}\n`); } if (definition.unverified && (typeof endMarkerOrFileResult === "string" || !endMarkerOrFileResult.unverified)) { @@ -798,6 +798,18 @@ namespace FourSlash { }); } + private renderMarkers(markers: { text: string, fileName: string, position: number }[]) { + const filesToDisplay = ts.deduplicate(markers.map(m => m.fileName), ts.equateValues); + return filesToDisplay.map(fileName => { + const markersToRender = markers.filter(m => m.fileName === fileName).sort((a, b) => b.position - a.position); + let fileContent = this.tryGetFileContent(fileName) || ""; + for (const marker of markersToRender) { + fileContent = fileContent.slice(0, marker.position) + `\x1b[1;4m/*${marker.text}*/\x1b[0;31m` + fileContent.slice(marker.position); + } + return `// @Filename: ${fileName}\n${fileContent}`; + }).join("\n\n"); + } + private verifyDefinitionTextSpan(defs: ts.DefinitionInfoAndBoundSpan, startMarkerName: string) { const range = this.testData.ranges.find(range => this.markerName(range.marker!) === startMarkerName); diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index ea07f4f386fc4..6eb4414df25ac 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -324,6 +324,10 @@ namespace FourSlashInterface { this.state.verifyGoToType(arg0, endMarkerName); } + public goToSourceDefinition(startMarkerNames: ArrayOrSingle, end: { file: string } | ArrayOrSingle) { + this.state.verifyGoToSourceDefinition(startMarkerNames, end); + } + public goToDefinitionForMarkers(...markerNames: string[]) { this.state.verifyGoToDefinitionForMarkers(markerNames); } diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 0d9fd7a1aab5d..a8b0f43044808 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -282,7 +282,7 @@ namespace Harness.SourceMapRecorder { const sourceMapData = sourceMapDataList[i]; let prevSourceFile: ts.SourceFile | undefined; let currentFile: documents.TextDocument; - if (ts.endsWith(sourceMapData.sourceMap.file, ts.Extension.Dts)) { + if (ts.isDeclarationFileName(sourceMapData.sourceMap.file)) { if (sourceMapDataList.length > jsFiles.length) { currentFile = declarationFiles[Math.floor(i / 2)]; // When both kinds of source map are present, they alternate js/dts } diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 3de4f3962e69a..f98463b240bf0 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -115,31 +115,39 @@ namespace Harness { // let type = this.checker.getTypeAtLocation(node); let type = ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) ? this.checker.getTypeAtLocation(node.parent) : undefined; if (!type || type.flags & ts.TypeFlags.Any) type = this.checker.getTypeAtLocation(node); - const typeString = - // Distinguish `errorType`s from `any`s; but only if the file has no errors. - // Additionally, - // * the LHS of a qualified name - // * a binding pattern name - // * labels - // * the "global" in "declare global" - // * the "target" in "new.target" - // * names in import statements - // * type-only names in export statements - // * and intrinsic jsx tag names - // return `error`s via `getTypeAtLocation` - // But this is generally expected, so we don't call those out, either - (!this.hadErrorBaseline && - type.flags & ts.TypeFlags.Any && - !ts.isBindingElement(node.parent) && - !ts.isPropertyAccessOrQualifiedName(node.parent) && - !ts.isLabelName(node) && - !(ts.isModuleDeclaration(node.parent) && ts.isGlobalScopeAugmentation(node.parent)) && - !ts.isMetaProperty(node.parent) && - !this.isImportStatementName(node) && - !this.isExportStatementName(node) && - !this.isIntrinsicJsxTag(node)) ? - (type as ts.IntrinsicType).intrinsicName : - this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType); + // Distinguish `errorType`s from `any`s; but only if the file has no errors. + // Additionally, + // * the LHS of a qualified name + // * a binding pattern name + // * labels + // * the "global" in "declare global" + // * the "target" in "new.target" + // * names in import statements + // * type-only names in export statements + // * and intrinsic jsx tag names + // return `error`s via `getTypeAtLocation` + // But this is generally expected, so we don't call those out, either + let typeString: string; + if (!this.hadErrorBaseline && + type.flags & ts.TypeFlags.Any && + !ts.isBindingElement(node.parent) && + !ts.isPropertyAccessOrQualifiedName(node.parent) && + !ts.isLabelName(node) && + !(ts.isModuleDeclaration(node.parent) && ts.isGlobalScopeAugmentation(node.parent)) && + !ts.isMetaProperty(node.parent) && + !this.isImportStatementName(node) && + !this.isExportStatementName(node) && + !this.isIntrinsicJsxTag(node)) { + typeString = (type as ts.IntrinsicType).intrinsicName; + } + else { + typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType); + if (ts.isIdentifier(node) && ts.isTypeAliasDeclaration(node.parent) && node.parent.name === node && typeString === ts.idText(node)) { + // for a complex type alias `type T = ...`, showing "T : T" isn't very helpful for type tests. When the type produced is the same as + // the name of the type alias, recreate the type string without reusing the alias name + typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType | ts.TypeFormatFlags.InTypeAlias); + } + } return { line: lineAndCharacter.line, syntaxKind: node.kind, diff --git a/src/harness/vfsUtil.ts b/src/harness/vfsUtil.ts index 5eca1ce30bb02..63a3d6963d55e 100644 --- a/src/harness/vfsUtil.ts +++ b/src/harness/vfsUtil.ts @@ -55,12 +55,12 @@ namespace vfs { } = {}; private _cwd: string; // current working directory - private _time: number | Date | (() => number | Date); + private _time: number; private _shadowRoot: FileSystem | undefined; private _dirStack: string[] | undefined; constructor(ignoreCase: boolean, options: FileSystemOptions = {}) { - const { time = -1, files, meta } = options; + const { time = ts.TestFSWithWatch.timeIncrements, files, meta } = options; this.ignoreCase = ignoreCase; this.stringComparer = this.ignoreCase ? vpath.compareCaseInsensitive : vpath.compareCaseSensitive; this._time = time; @@ -167,16 +167,15 @@ namespace vfs { * * @link http://pubs.opengroup.org/onlinepubs/9699919799/functions/time.html */ - public time(value?: number | Date | (() => number | Date)): number { - if (value !== undefined && this.isReadonly) throw createIOError("EPERM"); - let result = this._time; - if (typeof result === "function") result = result(); - if (typeof result === "object") result = result.getTime(); - if (result === -1) result = Date.now(); + public time(value?: number): number { if (value !== undefined) { + if (this.isReadonly) throw createIOError("EPERM"); this._time = value; } - return result; + else if (!this.isReadonly) { + this._time += ts.TestFSWithWatch.timeIncrements; + } + return this._time; } /** @@ -809,7 +808,11 @@ namespace vfs { const baseBuffer = base._getBuffer(baseNode); // no difference if both buffers are the same reference - if (changedBuffer === baseBuffer) return false; + if (changedBuffer === baseBuffer) { + if (!options.includeChangedFileWithSameContent || changedNode.mtimeMs === baseNode.mtimeMs) return false; + container[basename] = new SameFileWithModifiedTime(changedBuffer); + return true; + } // no difference if both buffers are identical if (Buffer.compare(changedBuffer, baseBuffer) === 0) { @@ -839,7 +842,7 @@ namespace vfs { container[basename] = new Symlink(node.symlink); } else { - container[basename] = new File(node.buffer || ""); + container[basename] = new File(changed._getBuffer(node)); } return true; } @@ -1168,9 +1171,8 @@ namespace vfs { } export interface FileSystemOptions { - // Sets the initial timestamp for new files and directories, or the function used - // to calculate timestamps. - time?: number | Date | (() => number | Date); + // Sets the initial timestamp for new files and directories + time?: number; // A set of file system entries to initially add to the file system. files?: FileSet; @@ -1391,6 +1393,12 @@ namespace vfs { } } + export class SameFileWithModifiedTime extends File { + constructor(data: Buffer | string, metaAndEncoding?: { encoding?: string, meta?: Record }) { + super(data, metaAndEncoding); + } + } + /** Extended options for a hard link in a `FileSet` */ export class Link { public readonly path: string; @@ -1579,6 +1587,9 @@ namespace vfs { else if (entry instanceof Directory) { text += formatPatchWorker(file, entry.files); } + else if (entry instanceof SameFileWithModifiedTime) { + text += `//// [${file}] file changed its modified time\r\n`; + } else if (entry instanceof SameFileContentFile) { text += `//// [${file}] file written with same contents\r\n`; } diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 62c6cd042ef93..829d6e8fa41f4 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -360,7 +360,7 @@ interface Array { length: number; [n: number]: T; }` DynamicPolling = "RecursiveDirectoryUsingDynamicPriorityPolling" } - const timeIncrements = 1000; + export const timeIncrements = 1000; export interface TestServerHostOptions { useCaseSensitiveFileNames: boolean; executingFilePath: string; @@ -396,6 +396,7 @@ interface Array { length: number; [n: number]: T; }` private readonly currentDirectory: string; public require: ((initialPath: string, moduleName: string) => RequireResult) | undefined; public defaultWatchFileKind?: () => WatchFileKind | undefined; + public storeFilesChangingSignatureDuringEmit = true; watchFile: HostWatchFile; watchDirectory: HostWatchDirectory; constructor( diff --git a/src/harness/vpathUtil.ts b/src/harness/vpathUtil.ts index 44ef5b0f6af3f..ec573861fbb4d 100644 --- a/src/harness/vpathUtil.ts +++ b/src/harness/vpathUtil.ts @@ -108,7 +108,7 @@ namespace vpath { } export function isDeclaration(path: string) { - return ts.fileExtensionIsOneOf(path, [ts.Extension.Dmts, ts.Extension.Dcts, ts.Extension.Dts]); + return ts.isDeclarationFileName(path); } export function isSourceMap(path: string) { diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts index 50a10c7b33e89..e13da87bc71c7 100644 --- a/src/lib/es2020.bigint.d.ts +++ b/src/lib/es2020.bigint.d.ts @@ -673,6 +673,7 @@ interface DataView { * Gets the BigInt64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; @@ -680,6 +681,7 @@ interface DataView { * Gets the BigUint64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; @@ -687,8 +689,7 @@ interface DataView { * Stores a BigInt64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; @@ -696,8 +697,7 @@ interface DataView { * Stores a BigUint64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; } diff --git a/src/lib/es2022.d.ts b/src/lib/es2022.d.ts index 67a9199b5d6f4..7069e4ecdf1e9 100644 --- a/src/lib/es2022.d.ts +++ b/src/lib/es2022.d.ts @@ -1,5 +1,6 @@ /// /// /// +/// /// /// diff --git a/src/lib/es2022.intl.d.ts b/src/lib/es2022.intl.d.ts new file mode 100644 index 0000000000000..0672ec4d2d4d4 --- /dev/null +++ b/src/lib/es2022.intl.d.ts @@ -0,0 +1,91 @@ +declare namespace Intl { + + /** + * An object with some or all properties of the `Intl.Segmenter` constructor `options` parameter. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters) + */ + interface SegmenterOptions { + /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */ + localeMatcher?: "best fit" | "lookup" | undefined; + /** The type of input to be split */ + granularity?: "grapheme" | "word" | "sentence" | undefined; + } + + interface Segmenter { + /** + * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity. + * + * @param input - The text to be segmented as a `string`. + * + * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity. + */ + segment(input: string): Segments; + resolvedOptions(): ResolvedSegmenterOptions; + } + + interface ResolvedSegmenterOptions { + locale: string; + granularity: "grapheme" | "word" | "sentence"; + } + + interface Segments { + /** + * Returns an object describing the segment in the original string that includes the code unit at a specified index. + * + * @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`. + */ + containing(codeUnitIndex?: number): SegmentData; + + /** Returns an iterator to iterate over the segments. */ + [Symbol.iterator](): IterableIterator; + } + + interface SegmentData { + /** A string containing the segment extracted from the original input string. */ + segment: string; + /** The code unit index in the original input string at which the segment begins. */ + index: number; + /** The complete input string that was segmented. */ + input: string; + /** + * A boolean value only if granularity is "word"; otherwise, undefined. + * If granularity is "word", then isWordLike is true when the segment is word-like (i.e., consists of letters/numbers/ideographs/etc.); otherwise, false. + */ + isWordLike?: boolean; + } + + const Segmenter: { + prototype: Segmenter; + + /** + * Creates a new `Intl.Segmenter` object. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the `locales` argument, + * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters) + * with some or all options of `SegmenterOptions`. + * + * @returns [Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments) object. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter). + */ + new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: SegmenterOptions): Segmenter; + + /** + * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the `locales` argument, + * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf#parameters). + * with some or all possible options. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf) + */ + supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick): BCP47LanguageTag[]; + }; +} diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index d4d0bf3ffa098..75b9539cc7592 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -52,13 +52,13 @@ declare function decodeURIComponent(encodedURIComponent: string): string; /** * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. + * @param uri A value representing an unencoded URI. */ declare function encodeURI(uri: string): string; /** * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. + * @param uriComponent A value representing an unencoded URI component. */ declare function encodeURIComponent(uriComponent: string | number | boolean): string; @@ -1669,6 +1669,7 @@ interface DataView { * Gets the Float32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getFloat32(byteOffset: number, littleEndian?: boolean): number; @@ -1676,6 +1677,7 @@ interface DataView { * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getFloat64(byteOffset: number, littleEndian?: boolean): number; @@ -1690,12 +1692,14 @@ interface DataView { * Gets the Int16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getInt32(byteOffset: number, littleEndian?: boolean): number; @@ -1710,6 +1714,7 @@ interface DataView { * Gets the Uint16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getUint16(byteOffset: number, littleEndian?: boolean): number; @@ -1717,6 +1722,7 @@ interface DataView { * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getUint32(byteOffset: number, littleEndian?: boolean): number; @@ -1724,8 +1730,7 @@ interface DataView { * Stores an Float32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1733,8 +1738,7 @@ interface DataView { * Stores an Float64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1749,8 +1753,7 @@ interface DataView { * Stores an Int16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1758,8 +1761,7 @@ interface DataView { * Stores an Int32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1774,8 +1776,7 @@ interface DataView { * Stores an Uint16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1783,8 +1784,7 @@ interface DataView { * Stores an Uint32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } diff --git a/src/lib/libs.json b/src/lib/libs.json index 0dbe57f36fa8d..ad01b1dff2c9b 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -57,6 +57,7 @@ "es2021.intl", "es2022.array", "es2022.error", + "es2022.intl", "es2022.object", "es2022.string", "esnext.intl", diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 90c07e3c9da6a..b20a7942045c0 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1512,6 +1512,15 @@ + + + + + + + + + @@ -5340,18 +5349,6 @@ - - - - - - - - - - - - @@ -5988,6 +5985,15 @@ + + + + + + + + + @@ -13731,6 +13737,15 @@ + + + + + + + + + @@ -13968,15 +13983,6 @@ - - - - - - - - - @@ -15093,6 +15099,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index cf3646a049ab2..f6b570fc6ff3c 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1512,6 +1512,15 @@ + + + + + + + + + @@ -5340,18 +5349,6 @@ - - - - - - - - - - - - @@ -5988,6 +5985,15 @@ + + + + + + + + + @@ -13731,6 +13737,15 @@ + + + + + + + + + @@ -13968,15 +13983,6 @@ - - - - - - - - - @@ -15093,6 +15099,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 9498c63a4780d..f614e8f193251 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1521,6 +1521,15 @@ + + + + + + + + + @@ -5349,18 +5358,6 @@ - - - - - - - - - - - - @@ -5997,6 +5994,15 @@ + + + + + + + + + @@ -13740,6 +13746,15 @@ + + + + + + + + + @@ -13977,15 +13992,6 @@ - - - - - - - - - @@ -15102,6 +15108,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 19d68a960fb46..33b4db6a78c09 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1509,6 +1509,15 @@ + + + + + + + + + @@ -5337,18 +5346,6 @@ - - - - - - - - - - - - @@ -5985,6 +5982,15 @@ + + + + + + + + + @@ -13725,6 +13731,15 @@ + + + + + + + + + @@ -13962,15 +13977,6 @@ - - - - - - - - - @@ -15087,6 +15093,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index e3ae122d6c9ac..0892782e82dcb 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1524,6 +1524,15 @@ + + + + + + + + + @@ -5352,18 +5361,6 @@ - - - - - - - - - - - - @@ -6000,6 +5997,15 @@ + + + + + + + + + @@ -13743,6 +13749,15 @@ + + + + + + + + + @@ -13980,15 +13995,6 @@ - - - - - - - - - @@ -15105,6 +15111,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 632da2ccfe737..e2263e2549db3 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1524,6 +1524,15 @@ + + + + + + + + + @@ -5352,18 +5361,6 @@ - - - - - - - - - - - - @@ -6000,6 +5997,15 @@ + + + + + + + + + @@ -13743,6 +13749,15 @@ + + + + + + + + + @@ -13980,15 +13995,6 @@ - - - - - - - - - @@ -15105,6 +15111,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1adf647dea7c1..372de213b24f3 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1512,6 +1512,15 @@ + + + + + + + + + @@ -5340,18 +5349,6 @@ - - - - - - - - - - - - @@ -5988,6 +5985,15 @@ + + + + + + + + + @@ -13731,6 +13737,15 @@ + + + + + + + + + @@ -13968,15 +13983,6 @@ - - - - - - - - - @@ -15093,6 +15099,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6cda72d2a7b97..e222b1f13d789 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1512,6 +1512,15 @@ + + + + + + + + + @@ -5340,18 +5349,6 @@ - - - - - - - - - - - - @@ -5988,6 +5985,15 @@ + + + + + + + + + @@ -13731,6 +13737,15 @@ + + + + + + + + + @@ -13968,15 +13983,6 @@ - - - - - - - - - @@ -15093,6 +15099,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 465a1eb0a913d..fb0bd7b0c44de 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1512,6 +1512,15 @@ + + + + + + + + + @@ -5340,18 +5349,6 @@ - - - - - - - - - - - - @@ -5988,6 +5985,15 @@ + + + + + + + + + @@ -13731,6 +13737,15 @@ + + + + + + + + + @@ -13968,15 +13983,6 @@ - - - - - - - - - @@ -15093,6 +15099,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index a26c731b7f6fb..102654a92b6f7 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1502,6 +1502,15 @@ + + + + + + + + + @@ -5330,18 +5339,6 @@ - - - - - - - - - - - - @@ -5978,6 +5975,15 @@ + + + + + + + + + @@ -13718,6 +13724,15 @@ + + + + + + + + + @@ -13955,15 +13970,6 @@ - - - - - - - - - @@ -15080,6 +15086,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index b5b13ec65890f..303d5413039ae 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1505,6 +1505,15 @@ + + + + + + + + + @@ -5333,18 +5342,6 @@ - - - - - - - - - - - - @@ -5981,6 +5978,15 @@ + + + + + + + + + @@ -13721,6 +13727,15 @@ + + + + + + + + + @@ -13958,15 +13973,6 @@ - - - - - - - - - @@ -15083,6 +15089,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 28eef0fc4d4f2..2e8bc37a128a3 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1511,6 +1511,15 @@ + + + + + + + + + @@ -5339,18 +5348,6 @@ - - - - - - - - - - - - @@ -5987,6 +5984,15 @@ + + + + + + + + + @@ -13730,6 +13736,15 @@ + + + + + + + + + @@ -13967,15 +13982,6 @@ - - - - - - - - - @@ -15092,6 +15098,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index edd0e58592425..9ae2836efbf4d 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1505,6 +1505,15 @@ + + + + + + + + + @@ -5333,18 +5342,6 @@ - - - - - - - - - - - - @@ -5981,6 +5978,15 @@ + + + + + + + + + @@ -13724,6 +13730,15 @@ + + + + + + + + + @@ -13961,15 +13976,6 @@ - - - - - - - - - @@ -15086,6 +15092,15 @@ + + + + + + + + + diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5a81aff9cc461..d40294989ee68 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -715,6 +715,8 @@ namespace ts.server { readonly newInferredProjectName = createProjectNameFactoryWithCounter(makeInferredProjectName); /*@internal*/ readonly newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(makeAutoImportProviderProjectName); + /*@internal*/ + readonly newAuxiliaryProjectName = createProjectNameFactoryWithCounter(makeAuxiliaryProjectName); /** * Open files: with value being project root path, and key being Path of the file that is open */ @@ -989,13 +991,15 @@ namespace ts.server { private delayUpdateProjectGraph(project: Project) { project.markAsDirty(); - const projectName = project.getProjectName(); - this.pendingProjectUpdates.set(projectName, project); - this.throttledOperations.schedule(projectName, /*delay*/ 250, () => { - if (this.pendingProjectUpdates.delete(projectName)) { - updateProjectIfDirty(project); - } - }); + if (project.projectKind !== ProjectKind.AutoImportProvider && project.projectKind !== ProjectKind.Auxiliary) { + const projectName = project.getProjectName(); + this.pendingProjectUpdates.set(projectName, project); + this.throttledOperations.schedule(projectName, /*delay*/ 250, () => { + if (this.pendingProjectUpdates.delete(projectName)) { + updateProjectIfDirty(project); + } + }); + } } /*@internal*/ @@ -2297,7 +2301,7 @@ namespace ts.server { configFileExistenceInfo.config.watchedDirectoriesStale = undefined; } - private updateNonInferredProjectFiles(project: ExternalProject | ConfiguredProject | AutoImportProviderProject, files: T[], propertyReader: FilePropertyReader) { + private updateNonInferredProjectFiles(project: Project, files: T[], propertyReader: FilePropertyReader) { const projectRootFilesMap = project.getRootFilesMap(); const newRootScriptInfoMap = new Map(); @@ -3589,7 +3593,7 @@ namespace ts.server { const toRemoveScriptInfos = new Map(this.filenameToScriptInfo); this.filenameToScriptInfo.forEach(info => { // If script info is open or orphan, retain it and its dependencies - if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByAutoImportProvider()) { + if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) { // Otherwise if there is any source info that is alive, this alive too if (!info.sourceMapFilePath) return; let sourceInfos: Set | undefined; diff --git a/src/server/moduleSpecifierCache.ts b/src/server/moduleSpecifierCache.ts index e5114fb64460d..c4a26b3f80c4f 100644 --- a/src/server/moduleSpecifierCache.ts +++ b/src/server/moduleSpecifierCache.ts @@ -14,7 +14,7 @@ namespace ts.server { return cache.get(toFileName); }, set(fromFileName, toFileName, preferences, options, modulePaths, moduleSpecifiers) { - ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isAutoImportable*/ true)); + ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false)); // If any module specifiers were generated based off paths in node_modules, // a package.json file in that package was read and is an input to the cached. @@ -43,17 +43,17 @@ namespace ts.server { info.modulePaths = modulePaths; } else { - cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isAutoImportable*/ undefined)); + cache.set(toFileName, createInfo(modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined)); } }, - setIsAutoImportable(fromFileName, toFileName, preferences, options, isAutoImportable) { + setBlockedByPackageJsonDependencies(fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) { const cache = ensureCache(fromFileName, preferences, options); const info = cache.get(toFileName); if (info) { - info.isAutoImportable = isAutoImportable; + info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies; } else { - cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isAutoImportable)); + cache.set(toFileName, createInfo(/*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies)); } }, clear() { @@ -87,9 +87,9 @@ namespace ts.server { function createInfo( modulePaths: readonly ModulePath[] | undefined, moduleSpecifiers: readonly string[] | undefined, - isAutoImportable: boolean | undefined, + isBlockedByPackageJsonDependencies: boolean | undefined, ): ResolvedModuleSpecifierInfo { - return { modulePaths, moduleSpecifiers, isAutoImportable }; + return { modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies }; } } } diff --git a/src/server/project.ts b/src/server/project.ts index cabeb6d1e62e2..f4a4f51b46192 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -5,6 +5,7 @@ namespace ts.server { Configured, External, AutoImportProvider, + Auxiliary, } /* @internal */ @@ -32,7 +33,7 @@ namespace ts.server { result.jsxSize! += fileSize; break; case ScriptKind.TS: - if (fileExtensionIs(info.fileName, Extension.Dts)) { + if (isDeclarationFileName(info.fileName)) { result.dts += 1; result.dtsSize! += fileSize; } @@ -71,7 +72,7 @@ namespace ts.server { /* @internal */ export function hasNoTypeScriptSource(fileNames: string[]): boolean { - return !fileNames.some(fileName => (fileExtensionIs(fileName, Extension.Ts) && !fileExtensionIs(fileName, Extension.Dts)) || fileExtensionIs(fileName, Extension.Tsx)); + return !fileNames.some(fileName => (fileExtensionIs(fileName, Extension.Ts) && !isDeclarationFileName(fileName)) || fileExtensionIs(fileName, Extension.Tsx)); } /* @internal */ @@ -209,6 +210,9 @@ namespace ts.server { /*@internal*/ private packageJsonsForAutoImport: Set | undefined; + /*@internal*/ + private noDtsResolutionProject?: AuxiliaryProject | undefined; + /*@internal*/ getResolvedProjectReferenceToRedirect(_fileName: string): ResolvedProjectReference | undefined { return undefined; @@ -686,7 +690,7 @@ namespace ts.server { // Update the signature if (this.builderState && getEmitDeclarations(this.compilerOptions)) { - const dtsFiles = outputFiles.filter(f => fileExtensionIs(f.name, Extension.Dts)); + const dtsFiles = outputFiles.filter(f => isDeclarationFileName(f.name)); if (dtsFiles.length === 1) { const sourceFile = this.program!.getSourceFile(scriptInfo.fileName)!; const signature = this.projectService.host.createHash ? @@ -811,6 +815,10 @@ namespace ts.server { this.autoImportProviderHost.close(); } this.autoImportProviderHost = undefined; + if (this.noDtsResolutionProject) { + this.noDtsResolutionProject.close(); + } + this.noDtsResolutionProject = undefined; // signal language service to release source files acquired from document registry this.languageService.dispose(); @@ -1406,6 +1414,7 @@ namespace ts.server { const oldOptions = this.compilerOptions; this.compilerOptions = compilerOptions; this.setInternalCompilerOptionsForEmittingJsFiles(); + this.noDtsResolutionProject?.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject()); if (changesAffectModuleResolution(oldOptions, compilerOptions)) { // reset cached unresolved imports if changes in compiler options affected module resolution this.cachedUnresolvedImportsPerFile.clear(); @@ -1780,6 +1789,54 @@ namespace ts.server { getIncompleteCompletionsCache() { return this.projectService.getIncompleteCompletionsCache(); } + + /*@internal*/ + getNoDtsResolutionProject(rootFileNames: readonly string[]): Project { + Debug.assert(this.projectService.serverMode === LanguageServiceMode.Semantic); + if (!this.noDtsResolutionProject) { + this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject()); + } + + enumerateInsertsAndDeletes( + rootFileNames.map(toNormalizedPath), + this.noDtsResolutionProject.getRootFiles(), + getStringComparer(!this.useCaseSensitiveFileNames()), + pathToAdd => { + const info = this.projectService.getOrCreateScriptInfoNotOpenedByClient( + pathToAdd, + this.currentDirectory, + this.noDtsResolutionProject!.directoryStructureHost); + if (info) { + this.noDtsResolutionProject!.addRoot(info, pathToAdd); + } + }, + pathToRemove => { + // It may be preferable to remove roots only once project grows to a certain size? + const info = this.noDtsResolutionProject!.getScriptInfo(pathToRemove); + if (info) { + this.noDtsResolutionProject!.removeRoot(info); + } + }, + ); + + return this.noDtsResolutionProject; + } + + /*@internal*/ + private getCompilerOptionsForNoDtsResolutionProject() { + return { + ...this.getCompilerOptions(), + noDtsResolution: true, + allowJs: true, + maxNodeModuleJsDepth: 3, + diagnostics: false, + skipLibCheck: true, + sourceMap: false, + types: ts.emptyArray, + lib: ts.emptyArray, + noLib: true, + }; + } } function getUnresolvedImports(program: Program, cachedUnresolvedImportsPerFile: ESMap): SortedReadonlyArray { @@ -1920,6 +1977,32 @@ namespace ts.server { } } + class AuxiliaryProject extends Project { + constructor(projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions) { + super(projectService.newAuxiliaryProjectName(), + ProjectKind.Auxiliary, + projectService, + documentRegistry, + /*hasExplicitListOfFiles*/ false, + /*lastFileExceededProgramSize*/ undefined, + compilerOptions, + /*compileOnSaveEnabled*/ false, + /*watchOptions*/ undefined, + projectService.host, + /*currentDirectory*/ undefined); + } + + isOrphan(): boolean { + return true; + } + + /*@internal*/ + scheduleInvalidateResolutionsOfFailedLookupLocations(): void { + // Invalidation will happen on-demand as part of updateGraph + return; + } + } + export class AutoImportProviderProject extends Project { /*@internal*/ private static readonly maxDependencies = 10; @@ -2129,6 +2212,12 @@ namespace ts.server { return hasSameSetOfFiles; } + /*@internal*/ + scheduleInvalidateResolutionsOfFailedLookupLocations(): void { + // Invalidation will happen on-demand as part of updateGraph + return; + } + hasRoots() { return !!this.rootFileNames?.length; } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index df61ead170eb4..121b69895f947 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -83,6 +83,7 @@ namespace ts.server.protocol { SignatureHelp = "signatureHelp", /* @internal */ SignatureHelpFull = "signatureHelp-full", + FindSourceDefinition = "findSourceDefinition", Status = "status", TypeDefinition = "typeDefinition", ProjectInfo = "projectInfo", @@ -904,6 +905,10 @@ namespace ts.server.protocol { readonly command: CommandTypes.DefinitionAndBoundSpan; } + export interface FindSourceDefinitionRequest extends FileLocationRequest { + readonly command: CommandTypes.FindSourceDefinition; + } + export interface DefinitionAndBoundSpanResponse extends Response { readonly body: DefinitionInfoAndBoundSpan; } @@ -2398,6 +2403,7 @@ namespace ts.server.protocol { } export interface CompletionInfo { + readonly flags?: number; readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index a26fcc6748932..dedd30fe19b93 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -501,7 +501,7 @@ namespace ts.server { case 0: return Errors.ThrowNoProject(); case 1: - return ensureNotAutoImportProvider(this.containingProjects[0]); + return ensurePrimaryProjectKind(this.containingProjects[0]); default: // If this file belongs to multiple projects, below is the order in which default project is used // - for open script info, its default configured project during opening is default if info is part of it @@ -536,7 +536,7 @@ namespace ts.server { firstInferredProject = project; } } - return ensureNotAutoImportProvider(defaultConfiguredProject || + return ensurePrimaryProjectKind(defaultConfiguredProject || firstNonSourceOfProjectReferenceRedirect || firstConfiguredProject || firstExternalProject || @@ -622,8 +622,10 @@ namespace ts.server { } /*@internal*/ - isContainedByAutoImportProvider() { - return some(this.containingProjects, p => p.projectKind === ProjectKind.AutoImportProvider); + isContainedByBackgroundProject() { + return some( + this.containingProjects, + p => p.projectKind === ProjectKind.AutoImportProvider || p.projectKind === ProjectKind.Auxiliary); } /** @@ -669,8 +671,13 @@ namespace ts.server { } } - function ensureNotAutoImportProvider(project: Project | undefined) { - if (!project || project.projectKind === ProjectKind.AutoImportProvider) { + /** + * Throws an error if `project` is an AutoImportProvider or AuxiliaryProject, + * which are used in the background by other Projects and should never be + * reported as the default project for a ScriptInfo. + */ + function ensurePrimaryProjectKind(project: Project | undefined) { + if (!project || project.projectKind === ProjectKind.AutoImportProvider || project.projectKind === ProjectKind.Auxiliary) { return Errors.ThrowNoProject(); } return project; diff --git a/src/server/session.ts b/src/server/session.ts index 6deac433729e9..ecd5b76ac46f0 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -317,6 +317,7 @@ namespace ts.server { projects, defaultProject, initialLocation, + /*isForRename*/ true, (project, location, tryAddToTodo) => { const projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename); if (projectOutputs) { @@ -332,8 +333,8 @@ namespace ts.server { return outputs; } - function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition): DocumentPosition | undefined { - const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos); + function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition, isForRename: boolean): DocumentPosition | undefined { + const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, isForRename); const info = infos && firstOrUndefined(infos); return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined; } @@ -350,11 +351,12 @@ namespace ts.server { projects, defaultProject, initialLocation, + /*isForRename*/ false, (project, location, getMappedLocation) => { logger.info(`Finding references to ${location.fileName} position ${location.pos} in project ${project.getProjectName()}`); const projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos); if (projectOutputs) { - const clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined; + const clearIsDefinition = projectOutputs[0]?.references[0]?.isDefinition === undefined; for (const referencedSymbol of projectOutputs) { const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition)); const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ? @@ -417,7 +419,8 @@ namespace ts.server { projects: Projects, defaultProject: Project, initialLocation: TLocation, - cb: CombineProjectOutputCallback + isForRename: boolean, + cb: CombineProjectOutputCallback, ): void { const projectService = defaultProject.projectService; let toDo: ProjectAndLocation[] | undefined; @@ -430,7 +433,7 @@ namespace ts.server { // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. if (initialLocation) { - const defaultDefinition = getDefinitionLocation(defaultProject, initialLocation); + const defaultDefinition = getDefinitionLocation(defaultProject, initialLocation, isForRename); if (defaultDefinition) { const getGeneratedDefinition = memoize(() => defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ? defaultDefinition : @@ -1193,6 +1196,7 @@ namespace ts.server { containerName: info.containerName, kind: info.kind, name: info.name, + failedAliasResolution: info.failedAliasResolution, ...info.unverified && { unverified: info.unverified }, }; }); @@ -1228,6 +1232,159 @@ namespace ts.server { }; } + private findSourceDefinition(args: protocol.FileLocationRequestArgs): readonly protocol.DefinitionInfo[] { + const { file, project } = this.getFileAndProject(args); + const position = this.getPositionInFile(args, file); + const unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position); + let definitions: readonly DefinitionInfo[] = this.mapDefinitionInfoLocations(unmappedDefinitions || emptyArray, project).slice(); + const needsJsResolution = this.projectService.serverMode === LanguageServiceMode.Semantic && ( + !some(definitions, d => toNormalizedPath(d.fileName) !== file && !d.isAmbient) || + some(definitions, d => !!d.failedAliasResolution)); + + if (needsJsResolution) { + const definitionSet = createSet(d => d.textSpan.start, documentSpansEqual); + definitions?.forEach(d => definitionSet.add(d)); + const noDtsProject = project.getNoDtsResolutionProject([file]); + const ls = noDtsProject.getLanguageService(); + const jsDefinitions = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false) + ?.filter(d => toNormalizedPath(d.fileName) !== file); + if (some(jsDefinitions)) { + for (const jsDefinition of jsDefinitions) { + if (jsDefinition.unverified) { + const refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram()!, ls.getProgram()!); + if (some(refined)) { + for (const def of refined) { + definitionSet.add(def); + } + continue; + } + } + definitionSet.add(jsDefinition); + } + } + else { + const ambientCandidates = definitions.filter(d => toNormalizedPath(d.fileName) !== file && d.isAmbient); + for (const candidate of some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain()) { + const fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject); + if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) { + continue; + } + const noDtsProgram = ls.getProgram()!; + const fileToSearch = Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch)); + for (const match of searchForDeclaration(candidate.name, fileToSearch, noDtsProgram)) { + definitionSet.add(match); + } + } + } + definitions = arrayFrom(definitionSet.values()); + } + + definitions = definitions.filter(d => !d.isAmbient && !d.failedAliasResolution); + return this.mapDefinitionInfo(definitions, project); + + function findImplementationFileFromDtsFileName(fileName: string, resolveFromFile: string, auxiliaryProject: Project) { + const nodeModulesPathParts = getNodeModulePathParts(fileName); + if (nodeModulesPathParts && fileName.lastIndexOf(nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) { + // Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up. + const packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex); + const packageJsonCache = project.getModuleResolutionCache()?.getPackageJsonInfoCache(); + const compilerOptions = project.getCompilationSettings(); + const packageJson = getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions); + if (!packageJson) return undefined; + // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext - + // Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be + // resolved from the package root under --moduleResolution node + const entrypoints = getEntrypointsFromPackageJsonInfo( + packageJson, + { moduleResolution: ModuleResolutionKind.NodeJs }, + project, + project.getModuleResolutionCache()); + // This substring is correct only because we checked for a single `/node_modules/` at the top. + const packageNamePathPart = fileName.substring( + nodeModulesPathParts.topLevelPackageNameIndex + 1, + nodeModulesPathParts.packageRootIndex); + const packageName = getPackageNameFromTypesPackageName(unmangleScopedPackageName(packageNamePathPart)); + const path = project.toPath(fileName); + if (entrypoints && some(entrypoints, e => project.toPath(e) === path)) { + // This file was the main entrypoint of a package. Try to resolve that same package name with + // the auxiliary project that only resolves to implementation files. + const [implementationResolution] = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile); + return implementationResolution?.resolvedFileName; + } + else { + // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package. + const pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1); + const specifier = `${packageName}/${removeFileExtension(pathToFileInPackage)}`; + const [implementationResolution] = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile); + return implementationResolution?.resolvedFileName; + } + } + // We're not in node_modules, and we only get to this function if non-dts module resolution failed. + // I'm not sure what else I can do here that isn't already covered by that module resolution. + return undefined; + } + + // In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition + // for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later. + function getAmbientCandidatesByClimbingAccessChain(): readonly { name: string, fileName: string }[] { + const ls = project.getLanguageService(); + const program = ls.getProgram()!; + const initialNode = getTouchingPropertyName(program.getSourceFile(file)!, position); + if ((isStringLiteralLike(initialNode) || isIdentifier(initialNode)) && isAccessExpression(initialNode.parent)) { + return forEachNameInAccessChainWalkingLeft(initialNode, nameInChain => { + if (nameInChain === initialNode) return undefined; + const candidates = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false) + ?.filter(d => toNormalizedPath(d.fileName) !== file && d.isAmbient) + .map(d => ({ + fileName: d.fileName, + name: getTextOfIdentifierOrLiteral(initialNode) + })); + if (some(candidates)) { + return candidates; + } + }) || emptyArray; + } + return emptyArray; + } + + function tryRefineDefinition(definition: DefinitionInfo, program: Program, noDtsProgram: Program) { + const fileToSearch = noDtsProgram.getSourceFile(definition.fileName); + if (!fileToSearch) { + return undefined; + } + const initialNode = getTouchingPropertyName(program.getSourceFile(file)!, position); + const symbol = program.getTypeChecker().getSymbolAtLocation(initialNode); + const importSpecifier = symbol && getDeclarationOfKind(symbol, SyntaxKind.ImportSpecifier); + if (!importSpecifier) return undefined; + + const nameToSearch = importSpecifier.propertyName?.text || importSpecifier.name.text; + return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram); + } + + function searchForDeclaration(declarationName: string, fileToSearch: SourceFile, noDtsProgram: Program) { + const matches = FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch); + return mapDefined(matches, match => { + const symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match); + const decl = getDeclarationFromName(match); + if (symbol && decl) { + // I think the last argument to this is supposed to be the start node, but it doesn't seem important. + // Callers internal to GoToDefinition already get confused about this. + return GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true); + } + }); + } + + function ensureRoot(project: Project, fileName: string) { + const info = project.getScriptInfo(fileName); + if (!info) return false; + if (!project.containsScriptInfo(info)) { + project.addRoot(info); + project.updateGraph(); + } + return true; + } + } + private getEmitOutput(args: protocol.EmitOutputRequestArgs): EmitOutput | protocol.EmitOutput { const { file, project } = this.getFileAndProject(args); if (!project.shouldEmitFile(project.getScriptInfo(file))) { @@ -1931,7 +2088,7 @@ namespace ts.server { const compilationSettings = project.getCompilationSettings(); - if (!!compilationSettings.noEmit || fileExtensionIs(info.fileName, Extension.Dts) && !dtsChangeCanAffectEmit(compilationSettings)) { + if (!!compilationSettings.noEmit || isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) { // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled return undefined; } @@ -2479,7 +2636,7 @@ namespace ts.server { else { const info = this.projectService.getScriptInfo(fileNameInProject)!; // TODO: GH#18217 if (!info.isScriptOpen()) { - if (fileExtensionIs(fileNameInProject, Extension.Dts)) { + if (isDeclarationFileName(fileNameInProject)) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -2751,12 +2908,15 @@ namespace ts.server { [CommandNames.DefinitionFull]: (request: protocol.DefinitionRequest) => { return this.requiredResponse(this.getDefinition(request.arguments, /*simplifiedResult*/ false)); }, - [CommandNames.DefinitionAndBoundSpan]: (request: protocol.DefinitionRequest) => { + [CommandNames.DefinitionAndBoundSpan]: (request: protocol.DefinitionAndBoundSpanRequest) => { return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true)); }, - [CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionRequest) => { + [CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionAndBoundSpanRequest) => { return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); }, + [CommandNames.FindSourceDefinition]: (request: protocol.FindSourceDefinitionRequest) => { + return this.requiredResponse(this.findSourceDefinition(request.arguments)); + }, [CommandNames.EmitOutput]: (request: protocol.EmitOutputRequest) => { return this.requiredResponse(this.getEmitOutput(request.arguments)); }, diff --git a/src/server/utilitiesPublic.ts b/src/server/utilitiesPublic.ts index 026162133bcbb..7b28a9b17d367 100644 --- a/src/server/utilitiesPublic.ts +++ b/src/server/utilitiesPublic.ts @@ -122,6 +122,11 @@ namespace ts.server { return `/dev/null/autoImportProviderProject${counter}*`; } + /*@internal*/ + export function makeAuxiliaryProjectName(counter: number): string { + return `/dev/null/auxiliaryProject${counter}*`; + } + export function createSortedArray(): SortedArray { return [] as any as SortedArray; // TODO: GH#19873 } diff --git a/src/services/codefixes/addMissingAwait.ts b/src/services/codefixes/addMissingAwait.ts index 1a9110227e504..d8b16cd4e549b 100644 --- a/src/services/codefixes/addMissingAwait.ts +++ b/src/services/codefixes/addMissingAwait.ts @@ -17,7 +17,7 @@ namespace ts.codefix { Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, Diagnostics.Type_0_is_not_an_array_type.code, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, - Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, + Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code, diff --git a/src/services/codefixes/fixAddVoidToPromise.ts b/src/services/codefixes/fixAddVoidToPromise.ts index 5e6add96dac81..b088f69594a3b 100644 --- a/src/services/codefixes/fixAddVoidToPromise.ts +++ b/src/services/codefixes/fixAddVoidToPromise.ts @@ -3,6 +3,7 @@ namespace ts.codefix { const fixName = "addVoidToPromise"; const fixId = "addVoidToPromise"; const errorCodes = [ + Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code, Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code ]; registerCodeFix({ diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts index c2d72d291e352..e60b95f6c27c1 100644 --- a/src/services/codefixes/fixModuleAndTargetOptions.ts +++ b/src/services/codefixes/fixModuleAndTargetOptions.ts @@ -2,8 +2,8 @@ namespace ts.codefix { registerCodeFix({ errorCodes: [ - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { const compilerOptions = context.program.getCompilerOptions(); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index a33fe54ec2a7f..28fccba8190e3 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -194,7 +194,6 @@ namespace ts.codefix { const scriptTarget = getEmitScriptTarget(program.getCompilerOptions()); const flags = NodeBuilderFlags.NoTruncation - | NodeBuilderFlags.NoUndefinedOptionalParameterType | NodeBuilderFlags.SuppressAnyReturnType | NodeBuilderFlags.AllowEmptyTuple | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : NodeBuilderFlags.None); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 485fc02727990..5f9080201686d 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -83,7 +83,7 @@ namespace ts.codefix { const symbol = checker.getMergedSymbol(skipAlias(exportedSymbol, checker)); const exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider); const useRequire = shouldUseRequire(sourceFile, program); - const fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); + const fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); if (fix) { addImport({ fixes: [fix], symbolName, errorIdentifierText: undefined }); } @@ -310,7 +310,7 @@ namespace ts.codefix { : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true); const useRequire = shouldUseRequire(sourceFile, program); const isValidTypeOnlyUseSite = isValidTypeOnlyAliasUseSite(getTokenAtPosition(sourceFile, position)); - const fix = Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences)); + const fix = Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName, position }, isValidTypeOnlyUseSite, useRequire, host, preferences)); return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix( @@ -331,10 +331,10 @@ namespace ts.codefix { return fix && codeFixActionToCodeAction(codeActionForFix({ host, formatContext, preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, QuotePreference.Double, compilerOptions)); } - function getImportFixForSymbol(sourceFile: SourceFile, exportInfos: readonly SymbolExportInfo[], moduleSymbol: Symbol, symbolName: string, program: Program, position: number | undefined, isValidTypeOnlyUseSite: boolean, useRequire: boolean, host: LanguageServiceHost, preferences: UserPreferences) { + function getImportFixForSymbol(sourceFile: SourceFile, exportInfos: readonly SymbolExportInfo[], moduleSymbol: Symbol, program: Program, useNamespaceInfo: { position: number, symbolName: string } | undefined, isValidTypeOnlyUseSite: boolean, useRequire: boolean, host: LanguageServiceHost, preferences: UserPreferences) { Debug.assert(exportInfos.some(info => info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol), "Some exportInfo should match the specified moduleSymbol"); const packageJsonImportFilter = createPackageJsonImportFilter(sourceFile, preferences, host); - return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host); + return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host); } function codeFixActionToCodeAction({ description, changes, commands }: CodeFixAction): CodeAction { @@ -396,6 +396,9 @@ namespace ts.codefix { export function getModuleSpecifierForBestExportInfo( exportInfo: readonly SymbolExportInfo[], + symbolName: string, + position: number, + isValidTypeOnlyUseSite: boolean, importingFile: SourceFile, program: Program, host: LanguageServiceHost, @@ -403,13 +406,13 @@ namespace ts.codefix { packageJsonImportFilter?: PackageJsonImportFilter, fromCacheOnly?: boolean, ): { exportInfo?: SymbolExportInfo, moduleSpecifier: string, computedWithoutCacheCount: number } | undefined { - const { fixes, computedWithoutCacheCount } = getNewImportFixes( + const { fixes, computedWithoutCacheCount } = getImportFixes( + exportInfo, + { symbolName, position }, + isValidTypeOnlyUseSite, + /*useRequire*/ false, program, importingFile, - /*position*/ undefined, - /*isValidTypeOnlyUseSite*/ false, - /*useRequire*/ false, - exportInfo, host, preferences, fromCacheOnly); @@ -419,23 +422,46 @@ namespace ts.codefix { function getImportFixes( exportInfos: readonly SymbolExportInfo[], - symbolName: string, + useNamespaceInfo: { + symbolName: string, + position: number, + } | undefined, /** undefined only for missing JSX namespace */ - position: number | undefined, isValidTypeOnlyUseSite: boolean, useRequire: boolean, program: Program, sourceFile: SourceFile, host: LanguageServiceHost, preferences: UserPreferences, - ): readonly ImportFixWithModuleSpecifier[] { + fromCacheOnly?: boolean, + ): { computedWithoutCacheCount: number, fixes: readonly ImportFixWithModuleSpecifier[] } { const checker = program.getTypeChecker(); const existingImports = flatMap(exportInfos, info => getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions())); - const useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); + const useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker); const addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions()); - // Don't bother providing an action to add a new import if we can add to an existing one. - const addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences); - return [...(useNamespace ? [useNamespace] : emptyArray), ...addImport]; + if (addToExisting) { + // Don't bother providing an action to add a new import if we can add to an existing one. + return { + computedWithoutCacheCount: 0, + fixes: [...(useNamespace ? [useNamespace] : emptyArray), addToExisting], + }; + } + + const { fixes, computedWithoutCacheCount = 0 } = getFixesForAddImport( + exportInfos, + existingImports, + program, + sourceFile, + useNamespaceInfo?.position, + isValidTypeOnlyUseSite, + useRequire, + host, + preferences, + fromCacheOnly); + return { + computedWithoutCacheCount, + fixes: [...(useNamespace ? [useNamespace] : emptyArray), ...fixes], + }; } function tryUseExistingNamespaceImport(existingImports: readonly FixAddToExistingImportInfo[], symbolName: string, position: number, checker: TypeChecker): FixUseNamespaceImport | undefined { @@ -453,7 +479,7 @@ namespace ts.codefix { // and it is up to the user to decide which one fits best. return firstDefined(existingImports, ({ declaration }): FixUseNamespaceImport | undefined => { const namespacePrefix = getNamespaceLikeImportText(declaration); - const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(declaration); + const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(declaration)?.text; if (namespacePrefix && moduleSpecifier) { const moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports!.has(escapeLeadingUnderscores(symbolName))) { @@ -618,6 +644,7 @@ namespace ts.codefix { const compilerOptions = program.getCompilerOptions(); const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host); const getChecker = memoizeOne((isFromPackageJson: boolean) => isFromPackageJson ? host.getPackageJsonAutoImportProvider!()!.getTypeChecker() : program.getTypeChecker()); + const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(getEmitModuleResolutionKind(compilerOptions)); const getModuleSpecifiers = fromCacheOnly ? (moduleSymbol: Symbol) => ({ moduleSpecifiers: moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol: Symbol, checker: TypeChecker) => moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); @@ -629,19 +656,19 @@ namespace ts.codefix { const importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & SymbolFlags.Value); const addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; - return moduleSpecifiers?.map((moduleSpecifier): FixAddNewImport | FixAddJsdocTypeImport => + return mapDefined(moduleSpecifiers, (moduleSpecifier): FixAddNewImport | FixAddJsdocTypeImport | undefined => + rejectNodeModulesRelativePaths && pathContainsNodeModules(moduleSpecifier) ? undefined : // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - !importedSymbolHasValueMeaning && isJs && position !== undefined - ? { kind: ImportFixKind.JsdocTypeImport, moduleSpecifier, position, exportInfo, isReExport: i > 0 } - : { - kind: ImportFixKind.AddNew, - moduleSpecifier, - importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), - useRequire, - addAsTypeOnly, - exportInfo, - isReExport: i > 0, - } + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: ImportFixKind.JsdocTypeImport, moduleSpecifier, position, exportInfo, isReExport: i > 0 } : + { + kind: ImportFixKind.AddNew, + moduleSpecifier, + importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), + useRequire, + addAsTypeOnly, + exportInfo, + isReExport: i > 0, + } ); }); @@ -658,9 +685,10 @@ namespace ts.codefix { useRequire: boolean, host: LanguageServiceHost, preferences: UserPreferences, - ): readonly (FixAddNewImport | FixAddJsdocTypeImport)[] { + fromCacheOnly?: boolean, + ): { computedWithoutCacheCount?: number, fixes: readonly (FixAddNewImport | FixAddJsdocTypeImport)[] } { const existingDeclaration = firstDefined(existingImports, info => newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions())); - return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes; + return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly); } function newImportInfoFromExistingSpecifier( @@ -670,7 +698,7 @@ namespace ts.codefix { checker: TypeChecker, compilerOptions: CompilerOptions ): FixAddNewImport | undefined { - const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(declaration); + const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(declaration)?.text; if (moduleSpecifier) { const addAsTypeOnly = useRequire ? AddAsTypeOnly.NotAllowed @@ -782,7 +810,8 @@ namespace ts.codefix { const symbolName = umdSymbol.name; const exportInfo: readonly SymbolExportInfo[] = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: ExportKind.UMD, targetFlags: symbol.flags, isFromPackageJson: false }]; const useRequire = shouldUseRequire(sourceFile, program); - const fixes = getImportFixes(exportInfo, symbolName, isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences); + const position = isIdentifier(token) ? token.getStart(sourceFile) : undefined; + const fixes = getImportFixes(exportInfo, position ? { position, symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; return { fixes, symbolName, errorIdentifierText: tryCast(token, isIdentifier)?.text }; } function getUmdSymbol(token: Node, checker: TypeChecker): Symbol | undefined { @@ -835,7 +864,7 @@ namespace ts.codefix { case ModuleKind.None: // Fall back to the `import * as ns` style import. return ImportKind.Namespace; - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return importingFile.impliedNodeFormat === ModuleKind.ESNext ? ImportKind.Namespace : ImportKind.CommonJS; default: @@ -855,7 +884,7 @@ namespace ts.codefix { const useRequire = shouldUseRequire(sourceFile, program); const exportInfo = getExportInfos(symbolName, isJSXTagName(symbolToken), getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); const fixes = arrayFrom(flatMapIterator(exportInfo.entries(), ([_, exportInfos]) => - getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences))); + getImportFixes(exportInfos, { symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes)); return { fixes, symbolName, errorIdentifierText: symbolToken.text }; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 0e936a774d580..27066f7b72e64 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -96,7 +96,6 @@ namespace ts.Completions { } interface SymbolOriginInfoObjectLiteralMethod extends SymbolOriginInfo { - importAdder: codefix.ImportAdder, insertText: string, labelDetails: CompletionEntryLabelDetails, isSnippet?: true, @@ -165,71 +164,86 @@ namespace ts.Completions { TypeAssertionKeywords, TypeKeywords, TypeKeyword, // Literally just `type` - Last = TypeKeywords + Last = TypeKeyword } const enum GlobalsSearch { Continue, Success, Fail } interface ModuleSpecifierResolutioContext { - tryResolve: (exportInfo: readonly SymbolExportInfo[], isFromAmbientModule: boolean) => ModuleSpecifierResolutionResult | undefined; - resolutionLimitExceeded: () => boolean; + tryResolve: (exportInfo: readonly SymbolExportInfo[], symbolName: string, isFromAmbientModule: boolean) => ModuleSpecifierResolutionResult; + resolvedAny: () => boolean; + skippedAny: () => boolean; + resolvedBeyondLimit: () => boolean; } - interface ModuleSpecifierResolutionResult { + type ModuleSpecifierResolutionResult = "skipped" | "failed" | { exportInfo?: SymbolExportInfo; moduleSpecifier: string; - } + }; function resolvingModuleSpecifiers( logPrefix: string, host: LanguageServiceHost, program: Program, sourceFile: SourceFile, + position: number, preferences: UserPreferences, isForImportStatementCompletion: boolean, + isValidTypeOnlyUseSite: boolean, cb: (context: ModuleSpecifierResolutioContext) => TReturn, ): TReturn { const start = timestamp(); const packageJsonImportFilter = createPackageJsonImportFilter(sourceFile, preferences, host); - let resolutionLimitExceeded = false; + // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because + // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a + // relative path into node_modules), and we want to filter those completions out entirely. + // Import statement completions always need specifier resolution because the module specifier is + // part of their `insertText`, not the `codeActions` creating edits away from the cursor. + const needsFullResolution = isForImportStatementCompletion || moduleResolutionRespectsExports(getEmitModuleResolutionKind(program.getCompilerOptions())); + let skippedAny = false; let ambientCount = 0; let resolvedCount = 0; let resolvedFromCacheCount = 0; let cacheAttemptCount = 0; - const result = cb({ tryResolve, resolutionLimitExceeded: () => resolutionLimitExceeded }); + const result = cb({ + tryResolve, + skippedAny: () => skippedAny, + resolvedAny: () => resolvedCount > 0, + resolvedBeyondLimit: () => resolvedCount > moduleSpecifierResolutionLimit, + }); const hitRateMessage = cacheAttemptCount ? ` (${(resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1)}% hit rate)` : ""; host.log?.(`${logPrefix}: resolved ${resolvedCount} module specifiers, plus ${ambientCount} ambient and ${resolvedFromCacheCount} from cache${hitRateMessage}`); - host.log?.(`${logPrefix}: response is ${resolutionLimitExceeded ? "incomplete" : "complete"}`); + host.log?.(`${logPrefix}: response is ${skippedAny ? "incomplete" : "complete"}`); host.log?.(`${logPrefix}: ${timestamp() - start}`); return result; - function tryResolve(exportInfo: readonly SymbolExportInfo[], isFromAmbientModule: boolean): ModuleSpecifierResolutionResult | undefined { + function tryResolve(exportInfo: readonly SymbolExportInfo[], symbolName: string, isFromAmbientModule: boolean): ModuleSpecifierResolutionResult { if (isFromAmbientModule) { - const result = codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences); + const result = codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences); if (result) { ambientCount++; } - return result; + return result || "failed"; } - const shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < moduleSpecifierResolutionLimit; + const shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < moduleSpecifierResolutionLimit; const shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < moduleSpecifierResolutionCacheAttemptLimit; const result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache) - ? codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) + ? codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache) : undefined; if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) { - resolutionLimitExceeded = true; + skippedAny = true; } resolvedCount += result?.computedWithoutCacheCount || 0; - resolvedFromCacheCount += exportInfo.length - resolvedCount; + resolvedFromCacheCount += exportInfo.length - (result?.computedWithoutCacheCount || 0); if (shouldGetModuleSpecifierFromCache) { cacheAttemptCount++; } - return result; + return result || (needsFullResolution ? "failed" : "skipped"); } } @@ -359,8 +373,10 @@ namespace ts.Completions { host, program, file, + location.getStart(), preferences, /*isForImportStatementCompletion*/ false, + isValidTypeOnlyAliasUseSite(location), context => { const entries = mapDefined(previousResponse.entries, entry => { if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) { @@ -375,8 +391,12 @@ namespace ts.Completions { const { origin } = Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)); const info = exportMap.get(file.path, entry.data.exportMapKey); - const result = info && context.tryResolve(info, !isExternalModuleNameRelative(stripQuotes(origin.moduleSymbol.name))); - if (!result) return entry; + const result = info && context.tryResolve(info, entry.name, !isExternalModuleNameRelative(stripQuotes(origin.moduleSymbol.name))); + if (result === "skipped") return entry; + if (!result || result === "failed") { + host.log?.(`Unexpected failure resolving auto import for '${entry.name}' from '${entry.source}'`); + return undefined; + } const newOrigin: SymbolOriginInfoResolvedExport = { ...origin, @@ -391,7 +411,7 @@ namespace ts.Completions { return entry; }); - if (!context.resolutionLimitExceeded()) { + if (!context.skippedAny()) { previousResponse.isIncomplete = undefined; } @@ -400,6 +420,7 @@ namespace ts.Completions { ); previousResponse.entries = newEntries; + previousResponse.flags = (previousResponse.flags || 0) | CompletionInfoFlags.IsContinuation; return previousResponse; } @@ -553,7 +574,7 @@ namespace ts.Completions { if (keywordFilters !== KeywordCompletionFilters.None) { const entryNames = new Set(entries.map(e => e.name)); for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) { - if (!entryNames.has(keywordEntry.name)) { + if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)!) || !entryNames.has(keywordEntry.name)) { insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } @@ -571,12 +592,13 @@ namespace ts.Completions { } return { + flags: completionData.flags, isGlobalCompletion: isInSnippetScope, isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation, optionalReplacementSpan: getOptionalReplacementSpan(location), - entries + entries, }; } @@ -780,17 +802,13 @@ namespace ts.Completions { } if (origin && originIsObjectLiteralMethod(origin)) { - let importAdder; - ({ insertText, isSnippet, importAdder, labelDetails } = origin); + ({ insertText, isSnippet, labelDetails } = origin); if (!preferences.useLabelDetailsInCompletionEntries) { name = name + labelDetails.detail; labelDetails = undefined; } source = CompletionSource.ObjectLiteralMethodSnippet; sortText = SortText.SortBelow(sortText); - if (importAdder.hasFixes()) { - hasAction = true; - } } if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { @@ -1072,14 +1090,13 @@ namespace ts.Completions { options: CompilerOptions, preferences: UserPreferences, formatContext: formatting.FormatContext | undefined, - ): { insertText: string, isSnippet?: true, importAdder: codefix.ImportAdder, labelDetails: CompletionEntryLabelDetails } | undefined { + ): { insertText: string, isSnippet?: true, labelDetails: CompletionEntryLabelDetails } | undefined { const isSnippet = preferences.includeCompletionsWithSnippetText || undefined; let insertText: string = name; const sourceFile = enclosingDeclaration.getSourceFile(); - const importAdder = codefix.createImportAdder(sourceFile, program, preferences, host); - const method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder); + const method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences); if (!method) { return undefined; } @@ -1115,7 +1132,7 @@ namespace ts.Completions { method.type); const labelDetails = { detail: signaturePrinter.printNode(EmitHint.Unspecified, methodSignature, sourceFile) }; - return { isSnippet, insertText, importAdder, labelDetails }; + return { isSnippet, insertText, labelDetails }; }; @@ -1126,14 +1143,12 @@ namespace ts.Completions { program: Program, host: LanguageServiceHost, preferences: UserPreferences, - importAdder: codefix.ImportAdder, ): MethodDeclaration | undefined { const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } const checker = program.getTypeChecker(); - const scriptTarget = getEmitScriptTarget(program.getCompilerOptions()); const declaration = declarations[0]; const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName; const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); @@ -1163,15 +1178,10 @@ namespace ts.Completions { // We don't support overloads in object literals. return undefined; } - let typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, codefix.getNoopSymbolTrackerWithResolver({ program, host })); + const typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, codefix.getNoopSymbolTrackerWithResolver({ program, host })); if (!typeNode || !isFunctionTypeNode(typeNode)) { return undefined; } - const importableReference = codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); - if (importableReference) { - typeNode = importableReference.typeNode; - codefix.importSymbols(importAdder, importableReference.symbols); - } let body; if (preferences.includeCompletionsWithSnippetText) { @@ -1183,15 +1193,25 @@ namespace ts.Completions { body = factory.createBlock([], /* multiline */ true); } + const parameters = typeNode.parameters.map(typedParam => + factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + typedParam.dotDotDotToken, + typedParam.name, + typedParam.questionToken, + /*type*/ undefined, + typedParam.initializer, + )); return factory.createMethodDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, - (typeNode as FunctionTypeNode).typeParameters, - (typeNode as FunctionTypeNode).parameters, - (typeNode as FunctionTypeNode).type, + /*typeParameters*/ undefined, + parameters, + /*type*/ undefined, body); } default: @@ -1202,18 +1222,19 @@ namespace ts.Completions { function createSnippetPrinter( printerOptions: PrinterOptions, ) { + let escapes: TextChange[] | undefined; const baseWriter = textChanges.createWriter(getNewLineCharacter(printerOptions)); const printer = createPrinter(printerOptions, baseWriter); const writer: EmitTextWriter = { ...baseWriter, - write: s => baseWriter.write(escapeSnippetText(s)), + write: s => escapingWrite(s, () => baseWriter.write(s)), nonEscapingWrite: baseWriter.write, - writeLiteral: s => baseWriter.writeLiteral(escapeSnippetText(s)), - writeStringLiteral: s => baseWriter.writeStringLiteral(escapeSnippetText(s)), - writeSymbol: (s, symbol) => baseWriter.writeSymbol(escapeSnippetText(s), symbol), - writeParameter: s => baseWriter.writeParameter(escapeSnippetText(s)), - writeComment: s => baseWriter.writeComment(escapeSnippetText(s)), - writeProperty: s => baseWriter.writeProperty(escapeSnippetText(s)), + writeLiteral: s => escapingWrite(s, () => baseWriter.writeLiteral(s)), + writeStringLiteral: s => escapingWrite(s, () => baseWriter.writeStringLiteral(s)), + writeSymbol: (s, symbol) => escapingWrite(s, () => baseWriter.writeSymbol(s, symbol)), + writeParameter: s => escapingWrite(s, () => baseWriter.writeParameter(s)), + writeComment: s => escapingWrite(s, () => baseWriter.writeComment(s)), + writeProperty: s => escapingWrite(s, () => baseWriter.writeProperty(s)), }; return { @@ -1221,12 +1242,39 @@ namespace ts.Completions { printAndFormatSnippetList, }; + // The formatter/scanner will have issues with snippet-escaped text, + // so instead of writing the escaped text directly to the writer, + // generate a set of changes that can be applied to the unescaped text + // to escape it post-formatting. + function escapingWrite(s: string, write: () => void) { + const escaped = escapeSnippetText(s); + if (escaped !== s) { + const start = baseWriter.getTextPos(); + write(); + const end = baseWriter.getTextPos(); + escapes = append(escapes ||= [], { newText: escaped, span: { start, length: end - start } }); + } + else { + write(); + } + } + /* Snippet-escaping version of `printer.printList`. */ function printSnippetList( format: ListFormat, list: NodeArray, sourceFile: SourceFile | undefined, ): string { + const unescaped = printUnescapedSnippetList(format, list, sourceFile); + return escapes ? textChanges.applyChanges(unescaped, escapes) : unescaped; + } + + function printUnescapedSnippetList( + format: ListFormat, + list: NodeArray, + sourceFile: SourceFile | undefined, + ): string { + escapes = undefined; writer.clear(); printer.writeList(format, list, sourceFile, writer); return writer.getText(); @@ -1239,7 +1287,7 @@ namespace ts.Completions { formatContext: formatting.FormatContext, ): string { const syntheticFile = { - text: printSnippetList( + text: printUnescapedSnippetList( format, list, sourceFile), @@ -1259,7 +1307,11 @@ namespace ts.Completions { /* delta */ 0, { ...formatContext, options: formatOptions }); }); - return textChanges.applyChanges(syntheticFile.text, changes); + + const allChanges = escapes + ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) + : changes; + return textChanges.applyChanges(syntheticFile.text, allChanges); } } @@ -1732,29 +1784,6 @@ namespace ts.Completions { } } - if (source === CompletionSource.ObjectLiteralMethodSnippet) { - const enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken) as ObjectLiteralExpression; - const { importAdder } = getEntryForObjectLiteralMethodCompletion( - symbol, - name, - enclosingDeclaration, - program, - host, - compilerOptions, - preferences, - formatContext)!; - if (importAdder.hasFixes()) { - const changes = textChanges.ChangeTracker.with({ host, formatContext, preferences }, importAdder.writeFixes); - return { - sourceDisplay: undefined, - codeActions: [{ - changes, - description: diagnosticToString([Diagnostics.Includes_imports_of_types_referenced_by_0, name]), - }], - }; - } - } - if (originIsTypeOnlyAlias(origin)) { const codeAction = codefix.getPromoteTypeOnlyCompletionAction( sourceFile, @@ -1831,6 +1860,7 @@ namespace ts.Completions { readonly isRightOfOpenTag: boolean; readonly importCompletionNode?: Node; readonly hasUnresolvedAutoImports?: boolean; + readonly flags: CompletionInfoFlags; } type Request = | { readonly kind: CompletionDataKind.JsDocTagName | CompletionDataKind.JsDocTag } @@ -2015,6 +2045,7 @@ namespace ts.Completions { let location = getTouchingPropertyName(sourceFile, position); let keywordFilters = KeywordCompletionFilters.None; let isNewIdentifierLocation = false; + let flags = CompletionInfoFlags.None; if (contextToken) { const importStatementCompletion = getImportStatementCompletionInfo(contextToken); @@ -2035,6 +2066,7 @@ namespace ts.Completions { // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; + flags |= CompletionInfoFlags.IsImportStatementCompletion; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -2242,6 +2274,7 @@ namespace ts.Completions { isRightOfOpenTag, importCompletionNode, hasUnresolvedAutoImports, + flags, }; type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag | JSDocTemplateTag; @@ -2422,7 +2455,7 @@ namespace ts.Completions { moduleSymbol, symbol: firstAccessibleSymbol, targetFlags: skipAlias(firstAccessibleSymbol, typeChecker).flags, - }], sourceFile, program, host, preferences) || {}; + }], firstAccessibleSymbol.name, position, isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}; if (moduleSpecifier) { const origin: SymbolOriginInfoResolvedExport = { @@ -2682,6 +2715,7 @@ namespace ts.Completions { return; } + flags |= CompletionInfoFlags.MayIncludeAutoImports; // import { type | -> token text should be blank const isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -2701,8 +2735,10 @@ namespace ts.Completions { host, program, sourceFile, + position, preferences, !!importCompletionNode, + isValidTypeOnlyAliasUseSite(location), context => { exportInfo.search( sourceFile.path, @@ -2724,14 +2760,34 @@ namespace ts.Completions { return; } - const defaultExportInfo = find(info, isImportableExportInfo); - if (!defaultExportInfo) { + // Do a relatively cheap check to bail early if all re-exports are non-importable + // due to file location or package.json dependency filtering. For non-node16+ + // module resolution modes, getting past this point guarantees that we'll be + // able to generate a suitable module specifier, so we can safely show a completion, + // even if we defer computing the module specifier. + const firstImportableExportInfo = find(info, isImportableExportInfo); + if (!firstImportableExportInfo) { return; } - // If we don't need to resolve module specifiers, we can use any re-export that is importable at all - // (We need to ensure that at least one is importable to show a completion.) - const { exportInfo = defaultExportInfo, moduleSpecifier } = context.tryResolve(info, isFromAmbientModule) || {}; + // In node16+, module specifier resolution can fail due to modules being blocked + // by package.json `exports`. If that happens, don't show a completion item. + // N.B. in this resolution mode we always try to resolve module specifiers here, + // because we have to know now if it's going to fail so we can omit the completion + // from the list. + const result = context.tryResolve(info, symbolName, isFromAmbientModule) || {}; + if (result === "failed") return; + + // If we skipped resolving module specifiers, our selection of which ExportInfo + // to use here is arbitrary, since the info shown in the completion list derived from + // it should be identical regardless of which one is used. During the subsequent + // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick + // the best one based on the module specifier it produces. + let exportInfo = firstImportableExportInfo, moduleSpecifier; + if (result !== "skipped") { + ({ exportInfo = firstImportableExportInfo, moduleSpecifier } = result); + } + const isDefaultExport = exportInfo.exportKind === ExportKind.Default; const symbol = isDefaultExport && getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; @@ -2749,7 +2805,9 @@ namespace ts.Completions { } ); - hasUnresolvedAutoImports = context.resolutionLimitExceeded(); + hasUnresolvedAutoImports = context.skippedAny(); + flags |= context.resolvedAny() ? CompletionInfoFlags.ResolvedModuleSpecifiers : 0; + flags |= context.resolvedBeyondLimit() ? CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit : 0; } ); @@ -2819,6 +2877,7 @@ namespace ts.Completions { return; } const origin: SymbolOriginInfoObjectLiteralMethod = { kind: SymbolOriginInfoKind.ObjectLiteralMethod, ...entryProps }; + flags |= CompletionInfoFlags.MayIncludeMethodSnippets; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -3050,7 +3109,7 @@ namespace ts.Completions { // 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 - let canGetType = hasInitializer(rootDeclaration) || hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement; + let canGetType = hasInitializer(rootDeclaration) || !!getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement; if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) { if (isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent as Expression); diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index ffcec349cc663..698f82eda51b4 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -93,6 +93,8 @@ namespace ts { return highlightSpans(getAsyncAndAwaitOccurrences(node)); case SyntaxKind.YieldKeyword: return highlightSpans(getYieldOccurrences(node)); + case SyntaxKind.InKeyword: + return undefined; default: return isModifierKind(node.kind) && (isDeclaration(node.parent) || isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 88d7daf468bf1..7141bc12fd7cd 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -25,7 +25,7 @@ namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -58,7 +58,7 @@ namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. @@ -236,7 +236,7 @@ namespace ts { // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). - const otherBucketKey = !fileExtensionIs(path, Extension.Dts) && + const otherBucketKey = !isDeclarationFileName(path) && forEachEntry(buckets, (bucket, bucketKey) => bucketKey !== key && bucket.has(path) && bucketKey); if (otherBucketKey) { tracing.instant(tracing.Phase.Session, "documentRegistryBucketOverlap", { path, key1: otherBucketKey, key2: key }); diff --git a/src/services/exportInfoMap.ts b/src/services/exportInfoMap.ts index 4004815a4a6de..e8b52d48122ab 100644 --- a/src/services/exportInfoMap.ts +++ b/src/services/exportInfoMap.ts @@ -291,8 +291,8 @@ namespace ts { ): boolean { if (from === to) return false; const cachedResult = moduleSpecifierCache?.get(from.path, to.path, preferences, {}); - if (cachedResult?.isAutoImportable !== undefined) { - return cachedResult.isAutoImportable; + if (cachedResult?.isBlockedByPackageJsonDependencies !== undefined) { + return !cachedResult.isBlockedByPackageJsonDependencies; } const getCanonicalFileName = hostGetCanonicalFileName(moduleSpecifierResolutionHost); @@ -313,7 +313,7 @@ namespace ts { if (packageJsonFilter) { const isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); - moduleSpecifierCache?.setIsAutoImportable(from.path, to.path, preferences, {}, isAutoImportable); + moduleSpecifierCache?.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable); return isAutoImportable; } @@ -381,38 +381,45 @@ namespace ts { host.log?.("getExportInfoMap: cache miss or empty; calculating new results"); const compilerOptions = program.getCompilerOptions(); let moduleCount = 0; - forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, (moduleSymbol, moduleFile, program, isFromPackageJson) => { - if (++moduleCount % 100 === 0) cancellationToken?.throwIfCancellationRequested(); - const seenExports = new Map<__String, true>(); - const checker = program.getTypeChecker(); - const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - // Note: I think we shouldn't actually see resolved module symbols here, but weird merges - // can cause it to happen: see 'completionsImport_mergedReExport.ts' - if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add( - importingFile.path, - defaultInfo.symbol, - defaultInfo.exportKind === ExportKind.Default ? InternalSymbolName.Default : InternalSymbolName.ExportEquals, - moduleSymbol, - moduleFile, - defaultInfo.exportKind, - isFromPackageJson, - checker); - } - checker.forEachExportAndPropertyOfModule(moduleSymbol, (exported, key) => { - if (exported !== defaultInfo?.symbol && isImportableSymbol(exported, checker) && addToSeen(seenExports, key)) { + try { + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, (moduleSymbol, moduleFile, program, isFromPackageJson) => { + if (++moduleCount % 100 === 0) cancellationToken?.throwIfCancellationRequested(); + const seenExports = new Map<__String, true>(); + const checker = program.getTypeChecker(); + const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + // Note: I think we shouldn't actually see resolved module symbols here, but weird merges + // can cause it to happen: see 'completionsImport_mergedReExport.ts' + if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { cache.add( importingFile.path, - exported, - key, + defaultInfo.symbol, + defaultInfo.exportKind === ExportKind.Default ? InternalSymbolName.Default : InternalSymbolName.ExportEquals, moduleSymbol, moduleFile, - ExportKind.Named, + defaultInfo.exportKind, isFromPackageJson, checker); } + checker.forEachExportAndPropertyOfModule(moduleSymbol, (exported, key) => { + if (exported !== defaultInfo?.symbol && isImportableSymbol(exported, checker) && addToSeen(seenExports, key)) { + cache.add( + importingFile.path, + exported, + key, + moduleSymbol, + moduleFile, + ExportKind.Named, + isFromPackageJson, + checker); + } + }); }); - }); + } + catch (err) { + // Ensure cache is reset if operation is cancelled + cache.clear(); + throw err; + } host.log?.(`getExportInfoMap: done in ${timestamp() - start} ms`); return cache; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index aeac984d5dbb7..ba46b5d311f46 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1365,6 +1365,31 @@ namespace ts.FindAllReferences { } } + export function getTopMostDeclarationNamesInFile(declarationName: string, sourceFile: SourceFile): readonly Node[] { + const candidates = filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), name => !!getDeclarationFromName(name)); + return candidates.reduce((topMost, decl) => { + const depth = getDepth(decl); + if (!some(topMost.declarationNames) || depth === topMost.depth) { + topMost.declarationNames.push(decl); + topMost.depth = depth; + } + else if (depth < topMost.depth) { + topMost.declarationNames = [decl]; + topMost.depth = depth; + } + return topMost; + }, { depth: Infinity, declarationNames: [] as Node[] }).declarationNames; + + function getDepth(declaration: Node | undefined) { + let depth = 0; + while (declaration) { + declaration = getContainerNode(declaration); + depth++; + } + return depth; + } + } + export function someSignatureUsage( signature: SignatureDeclaration, sourceFiles: readonly SourceFile[], diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 5a9948cd35f72..b3e84023d175a 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -691,6 +691,10 @@ namespace ts.formatting { isListItem: boolean, isFirstListItem?: boolean): number { + if (nodeIsMissing(child)) { + return inheritedIndentation; + } + const childStartPos = child.getStart(sourceFile); const childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -778,6 +782,13 @@ namespace ts.formatting { let listDynamicIndentation = parentDynamicIndentation; let startLine = parentStartLine; + // node range is outside the target range - do not dive inside + if (!rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { + if (nodes.end < originalRange.pos) { + formattingScanner.skipToEndOf(nodes); + } + return; + } if (listStartToken !== SyntaxKind.Unknown) { // introduce a new indentation scope for lists (including list start and end tokens) diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 05bbc34041600..56ad87770ba7b 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -12,7 +12,7 @@ namespace ts.formatting { readEOFTokenRange(): TextRangeWithKind; getCurrentLeadingTrivia(): TextRangeWithKind[] | undefined; lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; + skipToEndOf(node: Node | NodeArray): void; skipToStartOf(node: Node): void; } @@ -286,7 +286,7 @@ namespace ts.formatting { return tokenInfo; } - function skipToEndOf(node: Node): void { + function skipToEndOf(node: Node | NodeArray): void { scanner.setTextPos(node.end); savedPos = scanner.getStartPos(); lastScanAction = undefined; diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 3b49ec4b64610..f9f742e65a451 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.GoToDefinition { - export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): readonly DefinitionInfo[] | undefined { + export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number, searchOtherFilesOnly?: boolean, stopAtAlias?: boolean): readonly DefinitionInfo[] | undefined { const resolvedRef = getReferenceAtPosition(sourceFile, position, program); const fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || emptyArray; if (resolvedRef?.file) { @@ -28,18 +28,49 @@ namespace ts.GoToDefinition { if (isStaticModifier(node) && isClassStaticBlockDeclaration(node.parent)) { const classDecl = node.parent.parent; - const symbol = getSymbol(classDecl, typeChecker); + const { symbol, failedAliasResolution } = getSymbol(classDecl, typeChecker, stopAtAlias); + const staticBlocks = filter(classDecl.members, isClassStaticBlockDeclaration); const containerName = symbol ? typeChecker.symbolToString(symbol, classDecl) : ""; const sourceFile = node.getSourceFile(); return map(staticBlocks, staticBlock => { let { pos } = moveRangePastModifiers(staticBlock); pos = skipTrivia(sourceFile.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, ScriptElementKind.constructorImplementationElement, "static {}", containerName, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, ScriptElementKind.constructorImplementationElement, "static {}", containerName, /*unverified*/ false, failedAliasResolution, { start: pos, length: "static".length }); }); } - const symbol = getSymbol(node, typeChecker); + let { symbol, failedAliasResolution } = getSymbol(node, typeChecker, stopAtAlias); + let fallbackNode = node; + + if (searchOtherFilesOnly && failedAliasResolution) { + // We couldn't resolve the specific import, try on the module specifier. + const importDeclaration = forEach([node, ...symbol?.declarations || emptyArray], n => findAncestor(n, isAnyImportOrBareOrAccessedRequire)); + const moduleSpecifier = importDeclaration && tryGetModuleSpecifierFromDeclaration(importDeclaration); + if (moduleSpecifier) { + ({ symbol, failedAliasResolution } = getSymbol(moduleSpecifier, typeChecker, stopAtAlias)); + fallbackNode = moduleSpecifier; + } + } + + if (!symbol && isModuleSpecifierLike(fallbackNode)) { + // We couldn't resolve the module specifier as an external module, but it could + // be that module resolution succeeded but the target was not a module. + const ref = sourceFile.resolvedModules?.get(fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode)); + if (ref) { + return [{ + name: fallbackNode.text, + fileName: ref.resolvedFileName, + containerName: undefined!, + containerKind: undefined!, + kind: ScriptElementKind.scriptElement, + textSpan: createTextSpan(0, 0), + failedAliasResolution, + isAmbient: isDeclarationFileName(ref.resolvedFileName), + unverified: fallbackNode !== node, + }]; + } + } // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol @@ -47,17 +78,19 @@ namespace ts.GoToDefinition { return concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } + if (searchOtherFilesOnly && every(symbol.declarations, d => d.getSourceFile().fileName === sourceFile.fileName)) return undefined; + const calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. if (calledDeclaration && !(isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) { - const sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); + const sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. if (typeChecker.getRootSymbols(symbol).some(s => symbolMatchesSignature(s, calledDeclaration))) { return [sigInfo]; } else { - const defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || emptyArray; + const defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || emptyArray; // For a 'super()' call, put the signature first, else put the variable first. return node.kind === SyntaxKind.SuperKeyword ? [sigInfo, ...defs] : [...defs, sigInfo]; } @@ -70,7 +103,7 @@ namespace ts.GoToDefinition { // assignment. This case and others are handled by the following code. if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - const definitions = shorthandSymbol?.declarations ? shorthandSymbol.declarations.map(decl => createDefinitionInfo(decl, typeChecker, shorthandSymbol, node)) : emptyArray; + const definitions = shorthandSymbol?.declarations ? shorthandSymbol.declarations.map(decl => createDefinitionInfo(decl, typeChecker, shorthandSymbol, node, /*unverified*/ false, failedAliasResolution)) : emptyArray; return concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || emptyArray); } @@ -95,7 +128,7 @@ namespace ts.GoToDefinition { }); } - return concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); + return concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution)); } /** @@ -199,25 +232,25 @@ namespace ts.GoToDefinition { } if (isImportMeta(node.parent) && node.parent.name === node) { - return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent); + return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false); } - const symbol = getSymbol(node, typeChecker); + const { symbol, failedAliasResolution } = getSymbol(node, typeChecker, /*stopAtAlias*/ false); if (!symbol) return undefined; const typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node); const returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker); - const fromReturnType = returnType && definitionFromType(returnType, typeChecker, node); + const fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution); // If a function returns 'void' or some other type with no definition, just return the function definition. - const typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node); + const typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & SymbolFlags.Value) && symbol.flags & SymbolFlags.Type ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node) + : !(symbol.flags & SymbolFlags.Value) && symbol.flags & SymbolFlags.Type ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } - function definitionFromType(type: Type, checker: TypeChecker, node: Node): readonly DefinitionInfo[] { + function definitionFromType(type: Type, checker: TypeChecker, node: Node, failedAliasResolution: boolean | undefined): readonly DefinitionInfo[] { return flatMap(type.isUnion() && !(type.flags & TypeFlags.Enum) ? type.types : [type], t => - t.symbol && getDefinitionFromSymbol(checker, t.symbol, node)); + t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution)); } function tryGetReturnTypeOfFunction(symbol: Symbol, type: Type, checker: TypeChecker): Type | undefined { @@ -259,19 +292,23 @@ namespace ts.GoToDefinition { return mapDefined(checker.getIndexInfosAtLocation(node), info => info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration)); } - function getSymbol(node: Node, checker: TypeChecker): Symbol | undefined { + function getSymbol(node: Node, checker: TypeChecker, stopAtAlias: boolean | undefined) { const symbol = checker.getSymbolAtLocation(node); // If this is an alias, and the request came at the declaration location // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol?.declarations && symbol.flags & SymbolFlags.Alias && shouldSkipAlias(node, symbol.declarations[0])) { + let failedAliasResolution = false; + if (symbol?.declarations && symbol.flags & SymbolFlags.Alias && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { const aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { - return aliased; + return { symbol: aliased }; + } + else { + failedAliasResolution = true; } } - return symbol; + return { symbol, failedAliasResolution }; } // Go to the original declaration for cases: @@ -286,28 +323,44 @@ namespace ts.GoToDefinition { if (node.parent === declaration) { return true; } - switch (declaration.kind) { - case SyntaxKind.ImportClause: - case SyntaxKind.ImportEqualsDeclaration: - return true; - case SyntaxKind.ImportSpecifier: - return declaration.parent.kind === SyntaxKind.NamedImports; - case SyntaxKind.BindingElement: - case SyntaxKind.VariableDeclaration: - return isInJSFile(declaration) && isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); - default: - return false; + if (declaration.kind === SyntaxKind.NamespaceImport) { + return false; } + return true; + } + + /** + * ```ts + * function f() {} + * f.foo = 0; + * ``` + * + * Here, `f` has two declarations: the function declaration, and the identifier in the next line. + * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so + * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a + * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this + * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the + * declaration looks like an assignment, that declaration is in no sense a definition for `f`. + * But that information is totally lost during binding and/or symbol merging, so we need to do + * our best to reconstruct it or use other heuristics. This function (and the logic around its + * calling) covers our tests but feels like a hack, and it would be great if someone could come + * up with a more precise definition of what counts as a definition. + */ + function isExpandoDeclaration(node: Declaration): boolean { + if (!isAssignmentDeclaration(node)) return false; + const containingAssignment = findAncestor(node, p => { + if (isAssignmentExpression(p)) return true; + if (!isAssignmentDeclaration(p as Declaration)) return "quit"; + return false; + }) as AssignmentExpression | undefined; + return !!containingAssignment && getAssignmentDeclarationKind(containingAssignment) === AssignmentDeclarationKind.Property; } - function getDefinitionFromSymbol(typeChecker: TypeChecker, symbol: Symbol, node: Node, declarationNode?: Node): DefinitionInfo[] | undefined { - // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties. - // For deduping purposes, we also want to exclude any declarationNodes if provided. - const filteredDeclarations = - filter(symbol.declarations, d => d !== declarationNode && (!isAssignmentDeclaration(d) || d === symbol.valueDeclaration)) - || undefined; - return getConstructSignatureDefinition() || getCallSignatureDefinition() || map(filteredDeclarations, declaration => createDefinitionInfo(declaration, typeChecker, symbol, node)); + function getDefinitionFromSymbol(typeChecker: TypeChecker, symbol: Symbol, node: Node, failedAliasResolution?: boolean, excludeDeclaration?: Node): DefinitionInfo[] | undefined { + const filteredDeclarations = filter(symbol.declarations, d => d !== excludeDeclaration); + const withoutExpandos = filter(filteredDeclarations, d => !isExpandoDeclaration(d)); + const results = some(withoutExpandos) ? withoutExpandos : filteredDeclarations; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || map(results, declaration => createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)); function getConstructSignatureDefinition(): DefinitionInfo[] | undefined { // Applicable only if we are in a new expression, or we are on a constructor declaration @@ -335,21 +388,21 @@ namespace ts.GoToDefinition { return declarations.length ? declarationsWithBody.length !== 0 ? declarationsWithBody.map(x => createDefinitionInfo(x, typeChecker, symbol, node)) - : [createDefinitionInfo(last(declarations), typeChecker, symbol, node)] + : [createDefinitionInfo(last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)] : undefined; } } /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ - function createDefinitionInfo(declaration: Declaration, checker: TypeChecker, symbol: Symbol, node: Node): DefinitionInfo { + export function createDefinitionInfo(declaration: Declaration, checker: TypeChecker, symbol: Symbol, node: Node, unverified?: boolean, failedAliasResolution?: boolean): DefinitionInfo { const symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol const symbolKind = SymbolDisplay.getSymbolKind(checker, symbol, node); const containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : ""; - return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName); + return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution); } /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(checker: TypeChecker, declaration: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string, textSpan?: TextSpan): DefinitionInfo { + function createDefinitionInfoFromName(checker: TypeChecker, declaration: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string, unverified?: boolean, failedAliasResolution?: boolean, textSpan?: TextSpan): DefinitionInfo { const sourceFile = declaration.getSourceFile(); if (!textSpan) { const name = getNameOfDeclaration(declaration) || declaration; @@ -367,7 +420,10 @@ namespace ts.GoToDefinition { sourceFile, FindAllReferences.getContextNode(declaration) ), - isLocal: !isDefinitionVisible(checker, declaration) + isLocal: !isDefinitionVisible(checker, declaration), + isAmbient: !!(declaration.flags & NodeFlags.Ambient), + unverified, + failedAliasResolution, }; } @@ -402,8 +458,8 @@ namespace ts.GoToDefinition { } } - function createDefinitionFromSignatureDeclaration(typeChecker: TypeChecker, decl: SignatureDeclaration): DefinitionInfo { - return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); + function createDefinitionFromSignatureDeclaration(typeChecker: TypeChecker, decl: SignatureDeclaration, failedAliasResolution?: boolean): DefinitionInfo { + return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution); } export function findReferenceInPosition(refs: readonly FileReference[], pos: number): FileReference | undefined { diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index f9a790e80acf9..6e17babb6fea5 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -217,6 +217,7 @@ namespace ts.refactor.extractSymbol { export const cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); export const cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); export const cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block"); + export const cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method"); } enum RangeFacts { @@ -225,10 +226,11 @@ namespace ts.refactor.extractSymbol { IsGenerator = 1 << 1, IsAsyncFunction = 1 << 2, UsesThis = 1 << 3, + UsesThisInFunction = 1 << 4, /** * The range is in a function which needs the 'static' modifier in a class */ - InStaticRegion = 1 << 4 + InStaticRegion = 1 << 5, } /** @@ -242,6 +244,10 @@ namespace ts.refactor.extractSymbol { * Used to ensure we don't turn something used outside the range free (or worse, resolve to a different entity). */ readonly declarations: Symbol[]; + /** + * If `this` is referring to a function instead of class, we need to retrieve its type. + */ + readonly thisNode: Node | undefined; } /** @@ -294,6 +300,8 @@ namespace ts.refactor.extractSymbol { // about what things need to be done as part of the extraction. let rangeFacts = RangeFacts.None; + let thisNode: Node | undefined; + if (!start || !end) { // cannot find either start or end node return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -336,7 +344,7 @@ namespace ts.refactor.extractSymbol { return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - return { targetRange: { range: statements, facts: rangeFacts, declarations } }; + return { targetRange: { range: statements, facts: rangeFacts, declarations, thisNode } }; } if (isReturnStatement(start) && !start.expression) { @@ -351,7 +359,7 @@ namespace ts.refactor.extractSymbol { if (errors) { return { errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node)!, facts: rangeFacts, declarations } }; // TODO: GH#18217 + return { targetRange: { range: getStatementOrExpressionRange(node)!, facts: rangeFacts, declarations, thisNode } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. @@ -453,6 +461,17 @@ namespace ts.refactor.extractSymbol { visit(nodeToCheck); + if (rangeFacts & RangeFacts.UsesThis) { + const container = getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); + if ( + container.kind === SyntaxKind.FunctionDeclaration || + (container.kind === SyntaxKind.MethodDeclaration && container.parent.kind === SyntaxKind.ObjectLiteralExpression) || + container.kind === SyntaxKind.FunctionExpression + ) { + rangeFacts |= RangeFacts.UsesThisInFunction; + } + } + return errors; function visit(node: Node) { @@ -494,6 +513,7 @@ namespace ts.refactor.extractSymbol { } else { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } break; case SyntaxKind.ArrowFunction: @@ -501,6 +521,7 @@ namespace ts.refactor.extractSymbol { forEachChild(node, function check(n) { if (isThis(n)) { rangeFacts |= RangeFacts.UsesThis; + thisNode = node; } else if (isClassLike(n) || (isFunctionLike(n) && !isArrowFunction(n))) { return false; @@ -559,6 +580,7 @@ namespace ts.refactor.extractSymbol { case SyntaxKind.ThisType: case SyntaxKind.ThisKeyword: rangeFacts |= RangeFacts.UsesThis; + thisNode = node; break; case SyntaxKind.LabeledStatement: { const label = (node as LabeledStatement).label; @@ -650,7 +672,7 @@ namespace ts.refactor.extractSymbol { */ function collectEnclosingScopes(range: TargetRange): Scope[] { let current: Node = isReadonlyArray(range.range) ? first(range.range) : range.range; - if (range.facts & RangeFacts.UsesThis) { + if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class const containingClass = getContainingClass(current); if (containingClass) { @@ -904,6 +926,8 @@ namespace ts.refactor.extractSymbol { let newFunction: MethodDeclaration | FunctionDeclaration; + const callThis = !!(range.facts & RangeFacts.UsesThisInFunction); + if (isClassLike(scope)) { // always create private method in TypeScript files const modifiers: Modifier[] = isJS ? [] : [factory.createModifier(SyntaxKind.PrivateKeyword)]; @@ -926,6 +950,23 @@ namespace ts.refactor.extractSymbol { ); } else { + if (callThis) { + parameters.unshift( + factory.createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ "this", + /*questionToken*/ undefined, + checker.typeToTypeNode( + checker.getTypeAtLocation(range.thisNode!), + scope, + NodeBuilderFlags.NoTruncation + ), + /*initializer*/ undefined, + ) + ); + } newFunction = factory.createFunctionDeclaration( /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [factory.createToken(SyntaxKind.AsyncKeyword)] : undefined, @@ -953,8 +994,15 @@ namespace ts.refactor.extractSymbol { // replace range with function call const called = getCalledExpression(scope, range, functionNameText); + if (callThis) { + callArguments.unshift(factory.createIdentifier("this")); + } + let call: Expression = factory.createCallExpression( - called, + callThis ? factory.createPropertyAccessExpression( + called, + "call" + ) : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { @@ -1710,6 +1758,10 @@ namespace ts.refactor.extractSymbol { constantErrorsPerScope[i].push(createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes)); } + if (targetRange.facts & RangeFacts.UsesThisInFunction && isClassLike(scopes[i])) { + functionErrorsPerScope[i].push(createDiagnosticForNode(targetRange.thisNode!, Messages.cannotExtractFunctionsContainingThisToMethod)); + } + let hasWrite = false; let readonlyClassPropertyWrite: Declaration | undefined; usagesPerScope[i].usages.forEach(value => { diff --git a/src/services/services.ts b/src/services/services.ts index 9e39d4a405330..ac731115bebda 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1768,9 +1768,9 @@ namespace ts { } /// Goto definition - function getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined { + function getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly?: boolean, stopAtAlias?: boolean): readonly DefinitionInfo[] | undefined { synchronizeHostData(); - return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); + return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias); } function getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined { diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 61f90c9817d7d..604a833742649 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -377,12 +377,12 @@ namespace ts.Completions.StringCompletions { function isEmitResolutionKindUsingNodeModules(compilerOptions: CompilerOptions): boolean { return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs || - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || + getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext; } function isEmitModuleResolutionRespectingExportMaps(compilerOptions: CompilerOptions) { - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext; } diff --git a/src/services/types.ts b/src/services/types.ts index 54bd93f7f32ce..82ed0b9412455 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -267,7 +267,7 @@ namespace ts { /* * Unlike `realpath and `readDirectory`, `readFile` and `fileExists` are now _required_ - * to properly acquire and setup source files under module: node12+ modes. + * to properly acquire and setup source files under module: node16+ modes. */ readFile(path: string, encoding?: string): string | undefined; fileExists(path: string): boolean; @@ -472,6 +472,12 @@ namespace ts { getSmartSelectionRange(fileName: string, position: number): SelectionRange; + /*@internal*/ + // eslint-disable-next-line @typescript-eslint/unified-signatures + getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: false, stopAtAlias: boolean): readonly DefinitionInfo[] | undefined; + /*@internal*/ + // eslint-disable-next-line @typescript-eslint/unified-signatures + getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: boolean, stopAtAlias: false): readonly DefinitionInfo[] | undefined; getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; @@ -1032,6 +1038,8 @@ namespace ts { containerName: string; unverified?: boolean; /* @internal */ isLocal?: boolean; + /* @internal */ isAmbient?: boolean; + /* @internal */ failedAliasResolution?: boolean; } export interface DefinitionInfoAndBoundSpan { @@ -1171,7 +1179,20 @@ namespace ts { argumentCount: number; } + // Do not change existing values, as they exist in telemetry. + export const enum CompletionInfoFlags { + None = 0, + MayIncludeAutoImports = 1 << 0, + IsImportStatementCompletion = 1 << 1, + IsContinuation = 1 << 2, + ResolvedModuleSpecifiers = 1 << 3, + ResolvedModuleSpecifiersBeyondLimit = 1 << 4, + MayIncludeMethodSnippets = 1 << 5, + } + export interface CompletionInfo { + /** For performance telemetry. */ + flags?: CompletionInfoFlags; /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 16d406f7d259d..18f85ceb26421 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1928,6 +1928,14 @@ namespace ts { }; } + export function moduleResolutionRespectsExports(moduleResolution: ModuleResolutionKind): boolean { + return moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext; + } + + export function moduleResolutionUsesNodeModules(moduleResolution: ModuleResolutionKind): boolean { + return moduleResolution === ModuleResolutionKind.NodeJs || moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext; + } + export function makeImportIfNecessary(defaultImport: Identifier | undefined, namedImports: readonly ImportSpecifier[] | undefined, moduleSpecifier: string, quotePreference: QuotePreference): ImportDeclaration | undefined { return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined; } diff --git a/src/testRunner/fourslashRunner.ts b/src/testRunner/fourslashRunner.ts index 4916ec6693f6e..b996542a0a55e 100644 --- a/src/testRunner/fourslashRunner.ts +++ b/src/testRunner/fourslashRunner.ts @@ -52,7 +52,7 @@ namespace Harness { const testIndex = fn.indexOf("tests/"); if (testIndex >= 0) fn = fn.substr(testIndex); - if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { + if (justName !== "fourslash.ts") { it(this.testSuiteName + " test " + justName + " runs correctly", () => { FourSlash.runFourSlashTest(this.basePath, this.testType, fn); }); diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 2caa9873f29dd..619d3f245c753 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -154,6 +154,7 @@ "unittests/tsc/incremental.ts", "unittests/tsc/listFilesOnly.ts", "unittests/tsc/projectReferences.ts", + "unittests/tsc/redirect.ts", "unittests/tsc/runWithoutArgs.ts", "unittests/tscWatch/consoleClearing.ts", "unittests/tscWatch/emit.ts", @@ -169,6 +170,7 @@ "unittests/tscWatch/watchEnvironment.ts", "unittests/tsserver/applyChangesToOpenFiles.ts", "unittests/tsserver/autoImportProvider.ts", + "unittests/tsserver/auxiliaryProject.ts", "unittests/tsserver/cachingFileSystemInformation.ts", "unittests/tsserver/cancellationToken.ts", "unittests/tsserver/compileOnSave.ts", diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 0c9a9fd954bf7..e2b48977106b6 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -159,7 +159,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'.", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -237,7 +237,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node12', 'nodenext'.", + messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index 87c3587ec2fed..872e9e8b17f71 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -215,6 +215,7 @@ namespace ts { extension: Extension.Ts, }, failedLookupLocations: [], + resolutionDiagnostics: [], }); assert.isDefined(cache.get("/sub")); assert.isUndefined(cache.get("/")); @@ -228,6 +229,7 @@ namespace ts { extension: Extension.Ts, }, failedLookupLocations: [], + resolutionDiagnostics: [], }); assert.isDefined(cache.get("/sub/dir/foo")); assert.isDefined(cache.get("/sub/dir")); @@ -243,6 +245,7 @@ namespace ts { extension: Extension.Ts, }, failedLookupLocations: [], + resolutionDiagnostics: [], }); assert.isDefined(cache.get("/foo/bar")); assert.isDefined(cache.get("/foo")); @@ -257,6 +260,7 @@ namespace ts { extension: Extension.Ts, }, failedLookupLocations: [], + resolutionDiagnostics: [], }); assert.isDefined(cache.get("/foo")); assert.isUndefined(cache.get("/")); @@ -270,6 +274,7 @@ namespace ts { extension: Extension.Ts, }, failedLookupLocations: [], + resolutionDiagnostics: [], }); assert.isDefined(cache.get("c:/foo")); assert.isDefined(cache.get("c:/")); @@ -279,6 +284,7 @@ namespace ts { cache.set("/foo/bar/baz", { resolvedModule: undefined, failedLookupLocations: [], + resolutionDiagnostics: [], }); assert.isDefined(cache.get("/foo/bar/baz")); assert.isDefined(cache.get("/foo/bar")); diff --git a/src/testRunner/unittests/publicApi.ts b/src/testRunner/unittests/publicApi.ts index 2a5581bc93e31..4bfce8288f500 100644 --- a/src/testRunner/unittests/publicApi.ts +++ b/src/testRunner/unittests/publicApi.ts @@ -130,6 +130,26 @@ describe("unittests:: Public APIs:: getTypeAtLocation", () => { const type = checker.getTypeAtLocation(file); assert.equal(type.flags, ts.TypeFlags.Any); }); + + it("returns an errorType for VariableDeclaration with BindingPattern name", () => { + const content = "const foo = [1];\n" + "const [a] = foo;"; + + const host = new fakes.CompilerHost(vfs.createFromFileSystem( + Harness.IO, + /*ignoreCase*/ true, + { documents: [new documents.TextDocument("/file.ts", content)], cwd: "/" })); + + const program = ts.createProgram({ + host, + rootNames: ["/file.ts"], + options: { noLib: true } + }); + + const checker = program.getTypeChecker(); + const file = program.getSourceFile("/file.ts")!; + const [declaration] = (ts.findLast(file.statements, ts.isVariableStatement) as ts.VariableStatement).declarationList.declarations; + assert.equal(checker.getTypeAtLocation(declaration).flags, ts.TypeFlags.Any); + }); }); describe("unittests:: Public APIs:: validateLocaleAndSetLanguage", () => { @@ -160,30 +180,34 @@ describe("unittests:: Public APIs:: validateLocaleAndSetLanguage", () => { }); describe("unittests:: Public APIs :: forEachChild of @param comments in JSDoc", () => { - const content = ` + it("finds correct children", () => { + const content = ` /** * @param The {@link TypeReferencesInAedoc}. */ var x `; - const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true); - const paramTag = sourceFile.getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0]; - const kids = paramTag.getChildren(); - const seen: Set = new Set(); - ts.forEachChild(paramTag, n => { - assert.strictEqual(/*actual*/ false, seen.has(n), "Found a duplicate-added child"); - seen.add(n); + const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true); + const paramTag = sourceFile.getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0]; + const kids = paramTag.getChildren(); + const seen: Set = new Set(); + ts.forEachChild(paramTag, n => { + assert.strictEqual(/*actual*/ false, seen.has(n), "Found a duplicate-added child"); + seen.add(n); + }); + assert.equal(5, kids.length); }); - assert.equal(5, kids.length); }); describe("unittests:: Public APIs:: getChild* methods on EndOfFileToken with JSDoc", () => { - const content = ` + it("finds correct children", () => { + const content = ` /** jsdoc comment attached to EndOfFileToken */ `; - const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true); - const endOfFileToken = sourceFile.getChildren()[1]; - assert.equal(endOfFileToken.getChildren().length, 1); - assert.equal(endOfFileToken.getChildCount(), 1); - assert.notEqual(endOfFileToken.getChildAt(0), /*expected*/ undefined); + const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true); + const endOfFileToken = sourceFile.getChildren()[1]; + assert.equal(endOfFileToken.getChildren().length, 1); + assert.equal(endOfFileToken.getChildCount(), 1); + assert.notEqual(endOfFileToken.getChildAt(0), /*expected*/ undefined); + }); }); diff --git a/src/testRunner/unittests/services/extract/ranges.ts b/src/testRunner/unittests/services/extract/ranges.ts index 34f379df26d3c..38d47f028402e 100644 --- a/src/testRunner/unittests/services/extract/ranges.ts +++ b/src/testRunner/unittests/services/extract/ranges.ts @@ -9,7 +9,7 @@ namespace ts { } const result = refactor.extractSymbol.getRangeToExtract(file, createTextSpanFromRange(selectionRange), /*userRequested*/ false); assert(result.targetRange === undefined, "failure expected"); - const sortedErrors = result.errors!.map(e => e.messageText as string).sort(); + const sortedErrors = result.errors.map(e => e.messageText as string).sort(); assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors"); }); } diff --git a/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts b/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts index a08365887de0a..3e3a81491b127 100644 --- a/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts +++ b/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts @@ -1,30 +1,6 @@ namespace ts { describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => { let outFileFs: vfs.FileSystem; - const enum Project { lib, app } - function relName(path: string) { - return path.slice(1); - } - type Sources = [string, readonly string[]]; - const enum Source { config, ts } - const sources: [Sources, Sources] = [ - [ - "/src/lib/tsconfig.json", - [ - "/src/lib/file0.ts", - "/src/lib/file1.ts", - "/src/lib/file2.ts", - "/src/lib/global.ts", - ] - ], - [ - "/src/app/tsconfig.json", - [ - "/src/app/file3.ts", - "/src/app/file4.ts" - ] - ] - ]; before(() => { outFileFs = loadProjectFromDisk("tests/projects/amdModulesWithOut"); }); @@ -43,20 +19,20 @@ namespace ts { modifyFs, modifyAgainFs }: VerifyOutFileScenarioInput) { - verifyTscIncrementalEdits({ + verifyTscWithEdits({ scenario: "amdModulesWithOut", subScenario, fs: () => outFileFs, commandLineArgs: ["--b", "/src/app", "--verbose"], baselineSourceMap: true, modifyFs, - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsUnchanged, - modifyFs: fs => appendText(fs, relName(sources[Project.lib][Source.ts][1]), "console.log(x);") + subScenario: "incremental-declaration-doesnt-change", + modifyFs: fs => appendText(fs, "/src/lib/file1.ts", "console.log(x);") }, ...(modifyAgainFs ? [{ - buildKind: BuildKind.IncrementalHeadersChange, + subScenario: "incremental-headers-change-without-dts-changes", modifyFs: modifyAgainFs }] : emptyArray), ] @@ -73,15 +49,15 @@ namespace ts { verifyOutFileScenario({ subScenario: "multiple prologues in all projects", modifyFs: fs => { - enableStrict(fs, sources[Project.lib][Source.config]); - addTestPrologue(fs, sources[Project.lib][Source.ts][0], `"myPrologue"`); - addTestPrologue(fs, sources[Project.lib][Source.ts][2], `"myPrologueFile"`); - addTestPrologue(fs, sources[Project.lib][Source.ts][3], `"myPrologue3"`); - enableStrict(fs, sources[Project.app][Source.config]); - addTestPrologue(fs, sources[Project.app][Source.ts][0], `"myPrologue"`); - addTestPrologue(fs, sources[Project.app][Source.ts][1], `"myPrologue2";`); + enableStrict(fs, "/src/lib/tsconfig.json"); + addTestPrologue(fs, "/src/lib/file0.ts", `"myPrologue"`); + addTestPrologue(fs, "/src/lib/file2.ts", `"myPrologueFile"`); + addTestPrologue(fs, "/src/lib/global.ts", `"myPrologue3"`); + enableStrict(fs, "/src/app/tsconfig.json"); + addTestPrologue(fs, "/src/app/file3.ts", `"myPrologue"`); + addTestPrologue(fs, "/src/app/file4.ts", `"myPrologue2";`); }, - modifyAgainFs: fs => addTestPrologue(fs, relName(sources[Project.lib][Source.ts][1]), `"myPrologue5"`) + modifyAgainFs: fs => addTestPrologue(fs, "/src/lib/file1.ts", `"myPrologue5"`) }); }); @@ -127,10 +103,10 @@ namespace ts { describe("stripInternal", () => { function stripInternalScenario(fs: vfs.FileSystem) { const internal = "/*@internal*/"; - replaceText(fs, sources[Project.app][Source.config], `"composite": true,`, `"composite": true, + replaceText(fs, "/src/app/tsconfig.json", `"composite": true,`, `"composite": true, "stripInternal": true,`); - replaceText(fs, sources[Project.lib][Source.ts][0], "const", `${internal} const`); - appendText(fs, sources[Project.lib][Source.ts][1], ` + replaceText(fs, "/src/lib/file0.ts", "const", `${internal} const`); + appendText(fs, "/src/lib/file1.ts", ` export class normalC { ${internal} constructor() { } ${internal} prop: string; @@ -162,16 +138,16 @@ ${internal} export enum internalEnum { a, b, c }`); verifyOutFileScenario({ subScenario: "stripInternal", modifyFs: stripInternalScenario, - modifyAgainFs: fs => replaceText(fs, sources[Project.lib][Source.ts][1], `export const`, `/*@internal*/ export const`), + modifyAgainFs: fs => replaceText(fs, "/src/lib/file1.ts", `export const`, `/*@internal*/ export const`), }); }); describe("when the module resolution finds original source file", () => { function modifyFs(fs: vfs.FileSystem) { // Make lib to output to parent dir - replaceText(fs, sources[Project.lib][Source.config], `"outFile": "module.js"`, `"outFile": "../module.js", "rootDir": "../"`); + replaceText(fs, "/src/lib/tsconfig.json", `"outFile": "module.js"`, `"outFile": "../module.js", "rootDir": "../"`); // Change reference to file1 module to resolve to lib/file1 - replaceText(fs, sources[Project.app][Source.ts][0], "file1", "lib/file1"); + replaceText(fs, "/src/app/file3.ts", "file1", "lib/file1"); } verifyTsc({ diff --git a/src/testRunner/unittests/tsbuild/configFileErrors.ts b/src/testRunner/unittests/tsbuild/configFileErrors.ts index 5d2229588709b..594c8e07cadd8 100644 --- a/src/testRunner/unittests/tsbuild/configFileErrors.ts +++ b/src/testRunner/unittests/tsbuild/configFileErrors.ts @@ -9,7 +9,7 @@ namespace ts { }); describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in config file", () => { - verifyTscIncrementalEdits({ + verifyTscWithEdits({ scenario: "configFileErrors", subScenario: "reports syntax errors in config file", fs: () => loadProjectFromFiles({ @@ -27,21 +27,18 @@ namespace ts { }` }), commandLineArgs: ["--b", "/src/tsconfig.json"], - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => replaceText(fs, "/src/tsconfig.json", ",", `, "declaration": true,`), subScenario: "reports syntax errors after change to config file" }, { - buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => appendText(fs, "/src/a.ts", "export function fooBar() { }"), subScenario: "reports syntax errors after change to ts file" }, noChangeRun, { - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => fs.writeFileSync( "/src/tsconfig.json", JSON.stringify({ diff --git a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts index 8ccfbe5fe4742..e9eacf1fa657c 100644 --- a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts +++ b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts @@ -1,11 +1,11 @@ namespace ts { describe("unittests:: tsbuild:: when containerOnly project is referenced", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "containerOnlyReferenced", subScenario: "verify that subsequent builds after initial build doesnt build anything", fs: () => loadProjectFromDisk("tests/projects/containerOnlyReferenced"), commandLineArgs: ["--b", "/src", "--verbose"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); }); } diff --git a/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts b/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts index c673cd11bcd6a..9994b24d32c2a 100644 --- a/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts +++ b/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts @@ -9,7 +9,7 @@ namespace ts { }); function verifyEmitDeclarationOnly(disableMap?: true) { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: `only dts output in circular import project with emitDeclarationOnly${disableMap ? "" : " and declarationMap"}`, fs: () => projFs, scenario: "emitDeclarationOnly", @@ -17,8 +17,8 @@ namespace ts { modifyFs: disableMap ? (fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) : undefined, - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsChange, + edits: [{ + subScenario: "incremental-declaration-changes", modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), }], }); @@ -26,7 +26,7 @@ namespace ts { verifyEmitDeclarationOnly(); verifyEmitDeclarationOnly(/*disableMap*/ true); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: `only dts output in non circular imports project with emitDeclarationOnly`, fs: () => projFs, scenario: "emitDeclarationOnly", @@ -35,17 +35,16 @@ namespace ts { fs.rimrafSync("/src/src/index.ts"); replaceText(fs, "/src/src/a.ts", `import { B } from "./b";`, `export class B { prop = "hello"; }`); }, - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsUnchanged, + subScenario: "incremental-declaration-doesnt-change", modifyFs: fs => replaceText(fs, "/src/src/a.ts", "export interface A {", `class C { } export interface A {`), }, { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), - }, ], }); diff --git a/src/testRunner/unittests/tsbuild/helpers.ts b/src/testRunner/unittests/tsbuild/helpers.ts index 05800deaaac4f..803a37e014fc6 100644 --- a/src/testRunner/unittests/tsbuild/helpers.ts +++ b/src/testRunner/unittests/tsbuild/helpers.ts @@ -78,26 +78,6 @@ namespace ts { }; } - export function getTime() { - let currentTime = 100; - return { tick, time, touch }; - - function tick() { - currentTime += 60_000; - } - - function time() { - return currentTime; - } - - function touch(fs: vfs.FileSystem, path: string) { - if (!fs.statSync(path).isFile()) { - throw new Error(`File ${path} does not exist`); - } - fs.utimesSync(path, new Date(time()), new Date(time())); - } - } - export const libContent = `${TestFSWithWatch.libFile.content} interface ReadonlyArray {} declare const console: { log(msg: any): void; };`; @@ -154,26 +134,6 @@ interface Symbol { fs.makeReadonly(); } - /** - * Gets the FS mountuing existing fs's /src and /lib folder - */ - export function getFsWithTime(baseFs: vfs.FileSystem) { - const { time, tick } = getTime(); - const host = new fakes.System(baseFs) as any as vfs.FileSystemResolverHost; - host.getWorkspaceRoot = notImplemented; - const resolver = vfs.createResolver(host); - const fs = new vfs.FileSystem(/*ignoreCase*/ true, { - files: { - ["/src"]: new vfs.Mount("/src", resolver), - ["/lib"]: new vfs.Mount("/lib", resolver) - }, - cwd: "/", - meta: { defaultLibLocation: "/lib" }, - time - }); - return { fs, time, tick }; - } - export function verifyOutputsPresent(fs: vfs.FileSystem, outputs: readonly string[]) { for (const output of outputs) { assert(fs.existsSync(output), `Expect file ${output} to exist`); @@ -249,7 +209,7 @@ interface Symbol { affectedFilesPendingEmit?: readonly ReadableProgramBuilderInfoFilePendingEmit[]; } type ReadableBuildInfo = Omit & { program: ReadableProgramBuildInfo | undefined; size: number; }; - function generateBuildInfoProgramBaseline(sys: System, originalWriteFile: System["writeFile"], buildInfoPath: string, buildInfo: BuildInfo) { + function generateBuildInfoProgramBaseline(sys: System, buildInfoPath: string, buildInfo: BuildInfo) { const fileInfos: ReadableProgramBuildInfo["fileInfos"] = {}; buildInfo.program?.fileInfos.forEach((fileInfo, index) => fileInfos[toFileName(index + 1 as ProgramBuildInfoFileId)] = toBuilderStateFileInfo(fileInfo)); const fileNamesList = buildInfo.program?.fileIdsList?.map(fileIdsListId => fileIdsListId.map(toFileName)); @@ -280,7 +240,7 @@ interface Symbol { size: getBuildInfoText({ ...buildInfo, version }).length, }; // For now its just JSON.stringify - originalWriteFile.call(sys, `${buildInfoPath}.readable.baseline.txt`, JSON.stringify(result, /*replacer*/ undefined, 2)); + sys.writeFile(`${buildInfoPath}.readable.baseline.txt`, JSON.stringify(result, /*replacer*/ undefined, 2)); function toFileName(fileId: ProgramBuildInfoFileId) { return buildInfo.program!.fileNames[fileId - 1]; @@ -306,16 +266,15 @@ interface Symbol { export function baselineBuildInfo( options: CompilerOptions, - sys: System & { writtenFiles: ReadonlyCollection; }, + sys: TscCompileSystem | tscWatch.WatchedSystem, originalReadCall?: System["readFile"], - originalWriteFile?: System["writeFile"], ) { const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); - if (!buildInfoPath || !sys.writtenFiles.has(toPathWithSystem(sys, buildInfoPath))) return; + if (!buildInfoPath || !sys.writtenFiles!.has(toPathWithSystem(sys, buildInfoPath))) return; if (!sys.fileExists(buildInfoPath)) return; const buildInfo = getBuildInfo((originalReadCall || sys.readFile).call(sys, buildInfoPath, "utf8")!); - generateBuildInfoProgramBaseline(sys, originalWriteFile || sys.writeFile, buildInfoPath, buildInfo); + generateBuildInfoProgramBaseline(sys, buildInfoPath, buildInfo); if (!outFile(options)) return; const { jsFilePath, declarationFilePath } = getOutputPathsForBundle(options, /*forceDts*/ false); @@ -328,135 +287,173 @@ interface Symbol { generateBundleFileSectionInfo(sys, originalReadCall || sys.readFile, baselineRecorder, bundle.dts, declarationFilePath); baselineRecorder.Close(); const text = baselineRecorder.lines.join("\r\n"); - (originalWriteFile || sys.writeFile).call(sys, `${buildInfoPath}.baseline.txt`, text); - } - - interface VerifyIncrementalCorrectness { - scenario: TscCompile["scenario"]; - commandLineArgs: TscCompile["commandLineArgs"]; - modifyFs: TscCompile["modifyFs"]; - incrementalModifyFs: TscIncremental["modifyFs"]; - tick: () => void; + sys.writeFile(`${buildInfoPath}.baseline.txt`, text); + } + interface VerifyTscEditDiscrepanciesInput { + index: number; + scenario: TestTscCompile["scenario"]; + subScenario: TestTscCompile["subScenario"]; + baselines: string[] | undefined; + commandLineArgs: TestTscCompile["commandLineArgs"]; + modifyFs: TestTscCompile["modifyFs"]; + editFs: TestTscEdit["modifyFs"]; baseFs: vfs.FileSystem; newSys: TscCompileSystem; - cleanBuildDiscrepancies: TscIncremental["cleanBuildDiscrepancies"]; - } - function verifyIncrementalCorrectness(input: () => VerifyIncrementalCorrectness, index: number, subScenario: TscCompile["subScenario"]) { - it(`Verify emit output file text is same when built clean for incremental scenario at:: ${index} ${subScenario}`, () => { - const { - scenario, commandLineArgs, cleanBuildDiscrepancies, - modifyFs, incrementalModifyFs, - tick, baseFs, newSys - } = input(); - const sys = tscCompile({ - scenario, - subScenario, - fs: () => baseFs.makeReadonly(), - commandLineArgs, - modifyFs: fs => { - tick(); - if (modifyFs) modifyFs(fs); - incrementalModifyFs(fs); - }, - disableUseFileVersionAsSignature: true, - }); - const discrepancies = cleanBuildDiscrepancies?.(); - for (const outputFile of arrayFrom(sys.writtenFiles.keys())) { - const cleanBuildText = sys.readFile(outputFile); - const incrementalBuildText = newSys.readFile(outputFile); - const descrepancyInClean = discrepancies?.get(outputFile); - if (isBuildInfoFile(outputFile)) { - // Check only presence and absence and not text as we will do that for readable baseline - assert.isTrue(sys.fileExists(`${outputFile}.readable.baseline.txt`), `Readable baseline should be present in clean build:: File:: ${outputFile}`); - assert.isTrue(newSys.fileExists(`${outputFile}.readable.baseline.txt`), `Readable baseline should be present in incremental build:: File:: ${outputFile}`); - if (descrepancyInClean === undefined) { - verifyPresenceAbsence(incrementalBuildText, cleanBuildText, `Incremental and clean tsbuildinfo file presence should match:: File:: ${outputFile}`); - } - else { - verifyTextEqual(incrementalBuildText, cleanBuildText, descrepancyInClean, `File: ${outputFile}`); - } - } - else if (!fileExtensionIs(outputFile, ".tsbuildinfo.readable.baseline.txt")) { - verifyTextEqual(incrementalBuildText, cleanBuildText, descrepancyInClean, `File: ${outputFile}`); - } - else if (incrementalBuildText !== cleanBuildText) { - // Verify build info without affectedFilesPendingEmit - const { buildInfo: incrementalBuildInfo, readableBuildInfo: incrementalReadableBuildInfo } = getBuildInfoForIncrementalCorrectnessCheck(incrementalBuildText); - const { buildInfo: cleanBuildInfo, readableBuildInfo: cleanReadableBuildInfo } = getBuildInfoForIncrementalCorrectnessCheck(cleanBuildText); - verifyTextEqual(incrementalBuildInfo, cleanBuildInfo, descrepancyInClean, `TsBuild info text without affectedFilesPendingEmit ${subScenario}:: ${outputFile}::\nIncremental buildInfoText:: ${incrementalBuildText}\nClean buildInfoText:: ${cleanBuildText}`); - if (descrepancyInClean === undefined) { - // Verify file info sigantures - verifyMapLike( - incrementalReadableBuildInfo?.program?.fileInfos, - cleanReadableBuildInfo?.program?.fileInfos, - (key, incrementalFileInfo, cleanFileInfo) => { - if (incrementalFileInfo.signature !== cleanFileInfo.signature && incrementalFileInfo.signature !== incrementalFileInfo.version) { - assert.fail(`Incremental signature should either be dts signature or file version for File:: ${key}:: Incremental:: ${JSON.stringify(incrementalFileInfo)}, Clean:: ${JSON.stringify(cleanFileInfo)}}`); - } - }, - `FileInfos:: File:: ${outputFile}` - ); - // Verify exportedModulesMap - verifyMapLike( - incrementalReadableBuildInfo?.program?.exportedModulesMap, - cleanReadableBuildInfo?.program?.exportedModulesMap, - (key, incrementalReferenceSet, cleanReferenceSet) => { - if (!arrayIsEqualTo(incrementalReferenceSet, cleanReferenceSet) && !arrayIsEqualTo(incrementalReferenceSet, incrementalReadableBuildInfo!.program!.referencedMap![key])) { - assert.fail(`Incremental Reference set should either be from dts or files reference map for File:: ${key}:: Incremental:: ${JSON.stringify(incrementalReferenceSet)}, Clean:: ${JSON.stringify(cleanReferenceSet)}, referenceMap:: ${JSON.stringify(incrementalReadableBuildInfo!.program!.referencedMap![key])}}`); - } - }, - `exportedModulesMap:: File:: ${outputFile}` - ); - // Verify that incrementally pending affected file emit are in clean build since clean build can contain more files compared to incremental depending of noEmitOnError option - if (incrementalReadableBuildInfo?.program?.affectedFilesPendingEmit) { - assert.isDefined(cleanReadableBuildInfo?.program?.affectedFilesPendingEmit, `Incremental build contains affectedFilesPendingEmit, clean build should also have it: ${outputFile}::\nIncremental buildInfoText:: ${incrementalBuildText}\nClean buildInfoText:: ${cleanBuildText}`); - let expectedIndex = 0; - incrementalReadableBuildInfo.program.affectedFilesPendingEmit.forEach(([actualFile]) => { - expectedIndex = findIndex(cleanReadableBuildInfo!.program!.affectedFilesPendingEmit!, ([expectedFile]) => actualFile === expectedFile, expectedIndex); - assert.notEqual(expectedIndex, -1, `Incremental build contains ${actualFile} file as pending emit, clean build should also have it: ${outputFile}::\nIncremental buildInfoText:: ${incrementalBuildText}\nClean buildInfoText:: ${cleanBuildText}`); - expectedIndex++; - }); + discrepancyExplanation: TestTscEdit["discrepancyExplanation"]; + } + function verifyTscEditDiscrepancies({ + index, scenario, subScenario, commandLineArgs, + discrepancyExplanation, baselines, + modifyFs, editFs, baseFs, newSys + }: VerifyTscEditDiscrepanciesInput): string[] | undefined { + const sys = testTscCompile({ + scenario, + subScenario, + fs: () => baseFs.makeReadonly(), + commandLineArgs, + modifyFs: fs => { + if (modifyFs) modifyFs(fs); + editFs(fs); + }, + disableUseFileVersionAsSignature: true, + }); + let headerAdded = false; + for (const outputFile of arrayFrom(sys.writtenFiles.keys())) { + const cleanBuildText = sys.readFile(outputFile); + const incrementalBuildText = newSys.readFile(outputFile); + if (isBuildInfoFile(outputFile)) { + // Check only presence and absence and not text as we will do that for readable baseline + if (!sys.fileExists(`${outputFile}.readable.baseline.txt`)) addBaseline(`Readable baseline not present in clean build:: File:: ${outputFile}`); + if (!newSys.fileExists(`${outputFile}.readable.baseline.txt`)) addBaseline(`Readable baseline not present in incremental build:: File:: ${outputFile}`); + verifyPresenceAbsence(incrementalBuildText, cleanBuildText, `Incremental and clean tsbuildinfo file presence differs:: File:: ${outputFile}`); + } + else if (!fileExtensionIs(outputFile, ".tsbuildinfo.readable.baseline.txt")) { + verifyTextEqual(incrementalBuildText, cleanBuildText, `File: ${outputFile}`); + } + else if (incrementalBuildText !== cleanBuildText) { + // Verify build info without affectedFilesPendingEmit + const { buildInfo: incrementalBuildInfo, readableBuildInfo: incrementalReadableBuildInfo } = getBuildInfoForIncrementalCorrectnessCheck(incrementalBuildText); + const { buildInfo: cleanBuildInfo, readableBuildInfo: cleanReadableBuildInfo } = getBuildInfoForIncrementalCorrectnessCheck(cleanBuildText); + verifyTextEqual(incrementalBuildInfo, cleanBuildInfo, `TsBuild info text without affectedFilesPendingEmit:: ${outputFile}::`); + // Verify file info sigantures + verifyMapLike( + incrementalReadableBuildInfo?.program?.fileInfos, + cleanReadableBuildInfo?.program?.fileInfos, + (key, incrementalFileInfo, cleanFileInfo) => { + if (incrementalFileInfo.signature !== cleanFileInfo.signature && incrementalFileInfo.signature !== incrementalFileInfo.version) { + return [ + `Incremental signature is neither dts signature nor file version for File:: ${key}`, + `Incremental:: ${JSON.stringify(incrementalFileInfo, /*replacer*/ undefined, 2)}`, + `Clean:: ${JSON.stringify(cleanFileInfo, /*replacer*/ undefined, 2)}` + ]; } + }, + `FileInfos:: File:: ${outputFile}` + ); + // Verify exportedModulesMap + verifyMapLike( + incrementalReadableBuildInfo?.program?.exportedModulesMap, + cleanReadableBuildInfo?.program?.exportedModulesMap, + (key, incrementalReferenceSet, cleanReferenceSet) => { + if (!arrayIsEqualTo(incrementalReferenceSet, cleanReferenceSet) && !arrayIsEqualTo(incrementalReferenceSet, incrementalReadableBuildInfo!.program!.referencedMap![key])) { + return [ + `Incremental Reference set is neither from dts nor files reference map for File:: ${key}::`, + `Incremental:: ${JSON.stringify(incrementalReferenceSet, /*replacer*/ undefined, 2)}`, + `Clean:: ${JSON.stringify(cleanReferenceSet, /*replacer*/ undefined, 2)}`, + `IncrementalReferenceMap:: ${JSON.stringify(incrementalReadableBuildInfo!.program!.referencedMap![key], /*replacer*/ undefined, 2)}`, + `CleanReferenceMap:: ${JSON.stringify(cleanReadableBuildInfo!.program!.referencedMap![key], /*replacer*/ undefined, 2)}`, + ]; + } + }, + `exportedModulesMap:: File:: ${outputFile}` + ); + // Verify that incrementally pending affected file emit are in clean build since clean build can contain more files compared to incremental depending of noEmitOnError option + if (incrementalReadableBuildInfo?.program?.affectedFilesPendingEmit) { + if (cleanReadableBuildInfo?.program?.affectedFilesPendingEmit === undefined) { + addBaseline( + `Incremental build contains affectedFilesPendingEmit, clean build does not have it: ${outputFile}::`, + `Incremental buildInfoText:: ${incrementalBuildText}`, + `Clean buildInfoText:: ${cleanBuildText}` + ); } + let expectedIndex = 0; + incrementalReadableBuildInfo.program.affectedFilesPendingEmit.forEach(([actualFile]) => { + expectedIndex = findIndex(cleanReadableBuildInfo!.program!.affectedFilesPendingEmit!, ([expectedFile]) => actualFile === expectedFile, expectedIndex); + if (expectedIndex === -1) { + addBaseline( + `Incremental build contains ${actualFile} file as pending emit, clean build does not have it: ${outputFile}::`, + `Incremental buildInfoText:: ${incrementalBuildText}`, + `Clean buildInfoText:: ${cleanBuildText}` + ); + } + expectedIndex++; + }); } } + } + if (!headerAdded && discrepancyExplanation) addBaseline("*** Supplied discrepancy explanation but didnt file any difference"); + return baselines; - function verifyTextEqual(incrementalText: string | undefined, cleanText: string | undefined, descrepancyInClean: CleanBuildDescrepancy | undefined, message: string) { - if (descrepancyInClean === undefined) { - assert.equal(incrementalText, cleanText, message); - return; + function verifyTextEqual(incrementalText: string | undefined, cleanText: string | undefined, message: string) { + if (incrementalText !== cleanText) writeNotEqual(incrementalText, cleanText, message); + } + + function verifyMapLike(incremental: MapLike | undefined, clean: MapLike | undefined, verifyValue: (key: string, incrementalValue: T, cleanValue: T) => string[] | undefined, message: string) { + verifyPresenceAbsence(incremental, clean, `Incremental and clean do not match:: ${message}`); + if (!incremental || !clean) return; + const incrementalMap = new Map(getEntries(incremental)); + const cleanMap = new Map(getEntries(clean)); + if (incrementalMap.size !== cleanMap.size) { + addBaseline( + `Incremental and clean size of maps do not match:: ${message}`, + `Incremental: ${JSON.stringify(incremental, /*replacer*/ undefined, 2)}`, + `Clean: ${JSON.stringify(clean, /*replacer*/ undefined, 2)}`, + ); + return; + } + cleanMap.forEach((cleanValue, key) => { + const incrementalValue = incrementalMap.get(key); + if (!incrementalValue) { + addBaseline( + `Incremental does not contain ${key} which is present in clean:: ${message}`, + `Incremental: ${JSON.stringify(incremental, /*replacer*/ undefined, 2)}`, + `Clean: ${JSON.stringify(clean, /*replacer*/ undefined, 2)}`, + ); } - switch (descrepancyInClean) { - case CleanBuildDescrepancy.CleanFileTextDifferent: - assert.isDefined(incrementalText, `Incremental file should be present:: ${message}`); - assert.isDefined(cleanText, `Clean file should be present present:: ${message}`); - assert.notEqual(incrementalText, cleanText, message); - return; - case CleanBuildDescrepancy.CleanFilePresent: - assert.isUndefined(incrementalText, `Incremental file should be absent:: ${message}`); - assert.isDefined(cleanText, `Clean file should be present:: ${message}`); - return; - default: - Debug.assertNever(descrepancyInClean); + else { + const result = verifyValue(key, incrementalMap.get(key)!, cleanValue); + if (result) addBaseline(...result); } - } + }); + } - function verifyMapLike(incremental: MapLike | undefined, clean: MapLike | undefined, verifyValue: (key: string, incrementalValue: T, cleanValue: T) => void, message: string) { - verifyPresenceAbsence(incremental, clean, `Incremental and clean presence should match:: ${message}`); - if (!incremental) return; - const incrementalMap = new Map(getEntries(incremental)); - const cleanMap = new Map(getEntries(clean!)); - assert.equal(incrementalMap.size, cleanMap.size, `Incremental and clean size of map should match:: ${message}, Incremental keys: ${arrayFrom(incrementalMap.keys())} Clean: ${arrayFrom(cleanMap.keys())}${TestFSWithWatch.getDiffInKeys(incrementalMap, arrayFrom(cleanMap.keys()))}`); - cleanMap.forEach((cleanValue, key) => { - assert.isTrue(incrementalMap.has(key), `Expected to contain ${key} in incremental map:: ${message}, Incremental keys: ${arrayFrom(incrementalMap.keys())}`); - verifyValue(key, incrementalMap.get(key)!, cleanValue); - }); + function verifyPresenceAbsence(actual: T | undefined, expected: T | undefined, message: string) { + if (expected === undefined) { + if (actual === undefined) return; } - }); - } + else { + if (actual !== undefined) return; + } + writeNotEqual(actual, expected, message); + } + + function writeNotEqual(actual: T | undefined, expected: T | undefined, message: string) { + addBaseline( + message, + "CleanBuild:", + isString(expected) ? expected : JSON.stringify(expected), + "IncrementalBuild:", + isString(actual) ? actual : JSON.stringify(actual), + ); + } - function verifyPresenceAbsence(actual: T | undefined, expected: T | undefined, message: string) { - (expected !== undefined ? assert.isDefined : assert.isUndefined)(actual, message); + function addBaseline(...text: string[]) { + if (!baselines || !headerAdded) { + (baselines ||= []).push(`${index}:: ${subScenario}`, ...(discrepancyExplanation?.()|| ["*** Needs explanation"])); + headerAdded = true; + } + baselines.push(...text); + } } function getBuildInfoForIncrementalCorrectnessCheck(text: string | undefined): { @@ -466,7 +463,7 @@ interface Symbol { if (!text) return { buildInfo: text }; const readableBuildInfo = JSON.parse(text) as ReadableBuildInfo; let sanitizedFileInfos: MapLike | undefined; - if (readableBuildInfo.program) { + if (readableBuildInfo.program?.fileInfos) { sanitizedFileInfos = {}; for (const id in readableBuildInfo.program.fileInfos) { if (hasProperty(readableBuildInfo.program.fileInfos, id)) { @@ -498,167 +495,54 @@ interface Symbol { CleanFilePresent, } - export interface TscIncremental { - buildKind: BuildKind; + export interface TestTscEdit { modifyFs: (fs: vfs.FileSystem) => void; - subScenario?: string; + subScenario: string; commandLineArgs?: readonly string[]; - cleanBuildDiscrepancies?: () => ESMap; + /** An array of lines to be printed in order when a discrepancy is detected */ + discrepancyExplanation?: () => readonly string[]; } - export interface VerifyTsBuildInput extends VerifyTsBuildInputWorker { - baselineIncremental?: boolean; + export interface VerifyTscWithEditsInput extends TestTscCompile { + edits: TestTscEdit[]; } - export function verifyTscIncrementalEdits(input: VerifyTsBuildInput) { - verifyTscIncrementalEditsWorker(input); - if (input.baselineIncremental) { - verifyTscIncrementalEditsWorker({ - ...input, - subScenario: `${input.subScenario} with incremental`, - commandLineArgs: [...input.commandLineArgs, "--incremental"], - }); - } - } - - export interface VerifyTsBuildInputWorker extends TscCompile { - incrementalScenarios: TscIncremental[]; - } - function verifyTscIncrementalEditsWorker({ - subScenario, fs, scenario, commandLineArgs, - baselineSourceMap, modifyFs, baselineReadFileCalls, baselinePrograms, - incrementalScenarios - }: VerifyTsBuildInputWorker) { - describe(`tsc ${commandLineArgs.join(" ")} ${scenario}:: ${subScenario}`, () => { - let tick: () => void; - let sys: TscCompileSystem; - let baseFs: vfs.FileSystem; - before(() => { - ({ fs: baseFs, tick } = getFsWithTime(fs())); - sys = tscCompile({ - scenario, - subScenario, - fs: () => baseFs.makeReadonly(), - commandLineArgs, - modifyFs: fs => { - if (modifyFs) modifyFs(fs); - tick(); - }, - baselineSourceMap, - baselineReadFileCalls, - baselinePrograms - }); - Debug.assert(!!incrementalScenarios.length, `${scenario}/${subScenario}:: No incremental scenarios, you probably want to use verifyTsc instead.`); - }); - after(() => { - baseFs = undefined!; - sys = undefined!; - tick = undefined!; - }); - describe("initialBuild", () => { - verifyTscBaseline(() => sys); - }); - - incrementalScenarios.forEach(({ - buildKind, - modifyFs: incrementalModifyFs, - subScenario: incrementalSubScenario, - commandLineArgs: incrementalCommandLineArgs, - cleanBuildDiscrepancies, - }, index) => { - describe(incrementalSubScenario || buildKind, () => { - let newSys: TscCompileSystem; - before(() => { - Debug.assert(buildKind !== BuildKind.Initial, "Incremental edit cannot be initial compilation"); - tick(); - newSys = tscCompile({ - scenario, - subScenario: incrementalSubScenario || subScenario, - buildKind, - fs: () => sys.vfs, - commandLineArgs: incrementalCommandLineArgs || commandLineArgs, - modifyFs: fs => { - tick(); - incrementalModifyFs(fs); - tick(); - }, - baselineSourceMap, - baselineReadFileCalls, - baselinePrograms - }); - }); - after(() => { - newSys = undefined!; - }); - verifyTscBaseline(() => newSys); - verifyIncrementalCorrectness(() => ({ - scenario, - baseFs, - newSys, - commandLineArgs: incrementalCommandLineArgs || commandLineArgs, - cleanBuildDiscrepancies, - incrementalModifyFs, - modifyFs, - tick - }), index, incrementalSubScenario || subScenario); - }); - }); - }); - } - - export function verifyTscSerializedIncrementalEdits(input: VerifyTsBuildInput) { - verifyTscSerializedIncrementalEditsWorker(input); - if (input.baselineIncremental) { - verifyTscSerializedIncrementalEditsWorker({ - ...input, - subScenario: `${input.subScenario} with incremental`, - commandLineArgs: [...input.commandLineArgs, "--incremental"], - }); - } - } - function verifyTscSerializedIncrementalEditsWorker({ + /** + * Verify non watch tsc invokcation after each edit + */ + export function verifyTscWithEdits({ subScenario, fs, scenario, commandLineArgs, baselineSourceMap, modifyFs, baselineReadFileCalls, baselinePrograms, - incrementalScenarios - }: VerifyTsBuildInputWorker) { + edits + }: VerifyTscWithEditsInput) { describe(`tsc ${commandLineArgs.join(" ")} ${scenario}:: ${subScenario} serializedEdits`, () => { - Debug.assert(!!incrementalScenarios.length, `${scenario}/${subScenario}:: No incremental scenarios, you probably want to use verifyTsc instead.`); - let tick: () => void; let sys: TscCompileSystem; let baseFs: vfs.FileSystem; - let incrementalSys: TscCompileSystem[]; + let editsSys: TscCompileSystem[]; before(() => { - ({ fs: baseFs, tick } = getFsWithTime(fs())); - sys = tscCompile({ + Debug.assert(!!edits.length, `${scenario}/${subScenario}:: No incremental scenarios, you probably want to use verifyTsc instead.`); + baseFs = fs().makeReadonly(); + sys = testTscCompile({ scenario, subScenario, - fs: () => baseFs.makeReadonly(), + fs: () => baseFs, commandLineArgs, - modifyFs: fs => { - if (modifyFs) modifyFs(fs); - tick(); - }, + modifyFs, baselineSourceMap, baselineReadFileCalls, baselinePrograms }); - incrementalScenarios.forEach(( - { buildKind, modifyFs, subScenario: incrementalSubScenario, commandLineArgs: incrementalCommandLineArgs }, + edits.forEach(( + { modifyFs, subScenario: editScenario, commandLineArgs: editCommandLineArgs }, index ) => { - Debug.assert(buildKind !== BuildKind.Initial, "Incremental edit cannot be initial compilation"); - tick(); - (incrementalSys || (incrementalSys = [])).push(tscCompile({ + (editsSys || (editsSys = [])).push(testTscCompile({ scenario, - subScenario: incrementalSubScenario || subScenario, - buildKind, - fs: () => index === 0 ? sys.vfs : incrementalSys[index - 1].vfs, - commandLineArgs: incrementalCommandLineArgs || commandLineArgs, - modifyFs: fs => { - tick(); - modifyFs(fs); - tick(); - }, + subScenario: editScenario || subScenario, + diffWithInitial: true, + fs: () => index === 0 ? sys.vfs : editsSys[index - 1].vfs, + commandLineArgs: editCommandLineArgs || commandLineArgs, + modifyFs, baselineSourceMap, baselineReadFileCalls, baselinePrograms @@ -668,40 +552,45 @@ interface Symbol { after(() => { baseFs = undefined!; sys = undefined!; - tick = undefined!; - incrementalSys = undefined!; - }); - describe("serializedBuild", () => { - - verifyTscBaseline(() => ({ - baseLine: () => { - const { file, text } = sys.baseLine(); - const texts: string[] = [text]; - incrementalSys.forEach((sys, index) => { - const incrementalScenario = incrementalScenarios[index]; - texts.push(""); - texts.push(`Change:: ${incrementalScenario.subScenario || incrementalScenario.buildKind}`); - texts.push(sys.baseLine().text); - }); - return { file, text: texts.join("\r\n") }; - } - })); + editsSys = undefined!; }); - describe("incremental correctness", () => { - incrementalScenarios.forEach(({ commandLineArgs: incrementalCommandLineArgs, subScenario, buildKind, cleanBuildDiscrepancies }, index) => verifyIncrementalCorrectness(() => ({ - scenario, - baseFs, - newSys: incrementalSys[index], - commandLineArgs: incrementalCommandLineArgs || commandLineArgs, - cleanBuildDiscrepancies, - incrementalModifyFs: fs => { - for (let i = 0; i <= index; i++) { - incrementalScenarios[i].modifyFs(fs); - } - }, - modifyFs, - tick - }), index, subScenario || buildKind)); + verifyTscBaseline(() => ({ + baseLine: () => { + const { file, text } = sys.baseLine(); + const texts: string[] = [text]; + editsSys.forEach((sys, index) => { + const incrementalScenario = edits[index]; + texts.push(""); + texts.push(`Change:: ${incrementalScenario.subScenario}`); + texts.push(sys.baseLine().text); + }); + return { file, text: texts.join("\r\n") }; + } + })); + it("tsc invocation after edit and clean build correctness", () => { + let baselines: string[] | undefined; + for (let index = 0; index < edits.length; index++) { + baselines = verifyTscEditDiscrepancies({ + index, + scenario, + subScenario: edits[index].subScenario, + baselines, + baseFs, + newSys: editsSys[index], + commandLineArgs: edits[index].commandLineArgs || commandLineArgs, + discrepancyExplanation: edits[index].discrepancyExplanation, + editFs: fs => { + for (let i = 0; i <= index; i++) { + edits[i].modifyFs(fs); + } + }, + modifyFs + }); + } + Harness.Baseline.runBaseline( + `${isBuild(commandLineArgs) ? "tsbuild" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}-discrepancies.js`, + baselines ? baselines.join("\r\n") : null // eslint-disable-line no-null/no-null + ); }); }); } diff --git a/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts b/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts index e2d27de684a0a..2f8cc57d11175 100644 --- a/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts +++ b/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts @@ -8,42 +8,42 @@ namespace ts { projFs = undefined!; }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "inferredTypeFromTransitiveModule", subScenario: "inferred type from transitive module", fs: () => projFs, commandLineArgs: ["--b", "/src", "--verbose"], - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParam, }, { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParamBack, }, ], }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "inferred type from transitive module with isolatedModules", fs: () => projFs, scenario: "inferredTypeFromTransitiveModule", commandLineArgs: ["--b", "/src", "--verbose"], modifyFs: changeToIsolatedModules, - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParam }, { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParamBack, }, ] }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "inferredTypeFromTransitiveModule", subScenario: "reports errors in files affected by change in signature with isolatedModules", fs: () => projFs, @@ -54,22 +54,21 @@ namespace ts { import { default as bar } from './bar'; bar("hello");`); }, - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParam }, { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParamBack, }, { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: changeBarParam }, { subScenario: "Fix Error", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/lazyIndex.ts", `bar("hello")`, "bar()") }, ] diff --git a/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts b/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts index 6786205bb20a1..6a0f6d5bc156c 100644 --- a/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts +++ b/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts @@ -88,7 +88,7 @@ namespace ts { commandLineArgs: ["-b", "/src"] }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "javascriptProjectEmit", subScenario: `modifies outfile js projects and concatenates them correctly`, fs: () => loadProjectFromFiles({ @@ -176,8 +176,8 @@ namespace ts { }`, }, symbolLibContent), commandLineArgs: ["-b", "/src"], - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsUnchanged, + edits: [{ + subScenario: "incremental-declaration-doesnt-change", modifyFs: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined") }] }); diff --git a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts index 953e7f7f045a3..aeb075f5ab501 100644 --- a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts +++ b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts @@ -1,17 +1,17 @@ namespace ts { describe("unittests:: tsbuild:: lateBoundSymbol:: interface is merged and contains late bound member", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "interface is merged and contains late bound member", fs: () => loadProjectFromDisk("tests/projects/lateBoundSymbol"), scenario: "lateBoundSymbol", commandLineArgs: ["--b", "/src/tsconfig.json", "--verbose"], - incrementalScenarios: [ + edits: [ { - buildKind: BuildKind.IncrementalDtsUnchanged, + subScenario: "incremental-declaration-doesnt-change", modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""), }, { - buildKind: BuildKind.IncrementalDtsUnchanged, + subScenario: "incremental-declaration-doesnt-change", modifyFs: fs => appendText(fs, "/src/src/main.ts", "const x = 10;"), }, ] diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 0ac722293626f..10508b92404fd 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -90,7 +90,7 @@ namespace ts.tscWatch { content: JSON.stringify({ compilerOptions: { outDir: "build", - module: "node12", + module: "node16", }, references: [{ path: "../pkg2" }] }) @@ -109,7 +109,7 @@ namespace ts.tscWatch { compilerOptions: { composite: true, outDir: "build", - module: "node12", + module: "node16", } }) }, @@ -126,7 +126,7 @@ namespace ts.tscWatch { path: `${projectRoot}/node_modules/pkg2`, symLink: `${projectRoot}/packages/pkg2`, }, - { ...libFile, path: `/a/lib/lib.es2020.full.d.ts` } + { ...libFile, path: `/a/lib/lib.es2022.full.d.ts` } ], { currentDirectory: projectRoot }), commandLineArgs: ["-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"], changes: [ diff --git a/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts b/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts index 9c560a1bd6f4e..d8caa8997e784 100644 --- a/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts +++ b/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts @@ -89,7 +89,7 @@ namespace ts { }); }); - // https://github.com/microsoft/TypeScript/issues/44434 but with `module: node12`, some `exports` maps blocking direct access, and no `baseUrl` + // https://github.com/microsoft/TypeScript/issues/44434 but with `module: node16`, some `exports` maps blocking direct access, and no `baseUrl` describe("unittests:: tsbuild:: moduleSpecifiers:: synthesized module specifiers across referenced projects resolve correctly", () => { verifyTsc({ scenario: "moduleSpecifiers", @@ -140,7 +140,7 @@ namespace ts { { "compilerOptions": { "declaration": true, - "module": "node12" + "module": "node16" } }`, "/src/src-types/package.json": Utils.dedent` @@ -178,7 +178,7 @@ namespace ts { }`, }, ""), modifyFs: fs => { - fs.writeFileSync("/lib/lib.es2020.full.d.ts", tscWatch.libFile.content); + fs.writeFileSync("/lib/lib.es2022.full.d.ts", tscWatch.libFile.content); fs.symlinkSync("/src", "/src/src-types/node_modules"); fs.symlinkSync("/src", "/src/src-dogs/node_modules"); }, diff --git a/src/testRunner/unittests/tsbuild/noEmitOnError.ts b/src/testRunner/unittests/tsbuild/noEmitOnError.ts index 75e17f66203e9..f1aa1ac17c090 100644 --- a/src/testRunner/unittests/tsbuild/noEmitOnError.ts +++ b/src/testRunner/unittests/tsbuild/noEmitOnError.ts @@ -8,41 +8,81 @@ namespace ts { projFs = undefined!; }); - function verifyNoEmitOnError(subScenario: string, fixModifyFs: TscIncremental["modifyFs"], modifyFs?: TscIncremental["modifyFs"]) { - verifyTscSerializedIncrementalEdits({ - scenario: "noEmitOnError", - subScenario, - fs: () => projFs, - modifyFs, - commandLineArgs: ["--b", "/src/tsconfig.json"], - incrementalScenarios: [ - noChangeRun, - { - subScenario: "Fix error", - buildKind: BuildKind.IncrementalDtsChange, - modifyFs: fixModifyFs, - }, - noChangeRun, - ], - baselinePrograms: true, - baselineIncremental: true - }); - } + verifyTscWithEdits({ + scenario: "noEmitOnError", + subScenario: "syntax errors", + fs: () => projFs, + commandLineArgs: ["--b", "/src/tsconfig.json"], + edits: [ + noChangeRun, + { + subScenario: "Fix error", + modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; +const a = { + lastName: 'sdsd' +};`, "utf-8"), + }, + noChangeRun, + ], + baselinePrograms: true, + }); - verifyNoEmitOnError( - "syntax errors", - fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; + verifyTscWithEdits({ + scenario: "noEmitOnError", + subScenario: "syntax errors with incremental", + fs: () => projFs, + commandLineArgs: ["--b", "/src/tsconfig.json", "--incremental"], + edits: [ + noChangeRun, + { + subScenario: "Fix error", + modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; const a = { lastName: 'sdsd' -};`, "utf-8") - ); +};`, "utf-8"), + discrepancyExplanation: noChangeWithExportsDiscrepancyRun.discrepancyExplanation, + }, + noChangeWithExportsDiscrepancyRun, + ], + baselinePrograms: true, + }); - verifyNoEmitOnError( - "semantic errors", - fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; + verifyTscWithEdits({ + scenario: "noEmitOnError", + subScenario: "semantic errors", + fs: () => projFs, + modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`, "utf-8"), + commandLineArgs: ["--b", "/src/tsconfig.json"], + edits: [ + noChangeRun, + { + subScenario: "Fix error", + modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; const a: string = "hello";`, "utf-8"), - fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; -const a: string = 10;`, "utf-8") - ); + }, + noChangeRun, + ], + baselinePrograms: true, + }); + + verifyTscWithEdits({ + scenario: "noEmitOnError", + subScenario: "semantic errors with incremental", + fs: () => projFs, + modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = 10;`, "utf-8"), + commandLineArgs: ["--b", "/src/tsconfig.json", "--incremental"], + edits: [ + noChangeWithExportsDiscrepancyRun, + { + subScenario: "Fix error", + modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db"; +const a: string = "hello";`, "utf-8"), + }, + noChangeRun, + ], + baselinePrograms: true, + }); }); } diff --git a/src/testRunner/unittests/tsbuild/outFile.ts b/src/testRunner/unittests/tsbuild/outFile.ts index 33f7705085258..109ab200c69ef 100644 --- a/src/testRunner/unittests/tsbuild/outFile.ts +++ b/src/testRunner/unittests/tsbuild/outFile.ts @@ -1,84 +1,15 @@ namespace ts { describe("unittests:: tsbuild:: outFile::", () => { let outFileFs: vfs.FileSystem; - const enum Ext { js, jsmap, dts, dtsmap, buildinfo } - const enum Project { first, second, third } - type OutputFile = [string, string, string, string, string]; - function relName(path: string) { - return path.slice(1); - } - const outputFiles: [OutputFile, OutputFile, OutputFile] = [ - [ - "/src/first/bin/first-output.js", - "/src/first/bin/first-output.js.map", - "/src/first/bin/first-output.d.ts", - "/src/first/bin/first-output.d.ts.map", - "/src/first/bin/first-output.tsbuildinfo" - ], - [ - "/src/2/second-output.js", - "/src/2/second-output.js.map", - "/src/2/second-output.d.ts", - "/src/2/second-output.d.ts.map", - "/src/2/second-output.tsbuildinfo" - ], - [ - "/src/third/thirdjs/output/third-output.js", - "/src/third/thirdjs/output/third-output.js.map", - "/src/third/thirdjs/output/third-output.d.ts", - "/src/third/thirdjs/output/third-output.d.ts.map", - "/src/third/thirdjs/output/third-output.tsbuildinfo" - ] - ]; - const relOutputFiles = outputFiles.map(v => v.map(relName)) as [OutputFile, OutputFile, OutputFile]; - type Sources = [string, readonly string[]]; - const enum Source { config, ts } - const enum Part { one, two, three } - const sources: [Sources, Sources, Sources] = [ - [ - "/src/first/tsconfig.json", - [ - "/src/first/first_PART1.ts", - "/src/first/first_part2.ts", - "/src/first/first_part3.ts" - ] - ], - [ - "/src/second/tsconfig.json", - [ - "/src/second/second_part1.ts", - "/src/second/second_part2.ts" - ] - ], - [ - "/src/third/tsconfig.json", - [ - "/src/third/third_part1.ts" - ] - ] - ]; - const relSources = sources.map(([config, sources]) => [relName(config), sources.map(relName)]) as any as [Sources, Sources, Sources]; - let initialExpectedDiagnostics: readonly fakes.ExpectedDiagnostic[] = [ - getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[Project.first][Source.config], relOutputFiles[Project.first][Ext.js]], - [Diagnostics.Building_project_0, sources[Project.first][Source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[Project.second][Source.config], relOutputFiles[Project.second][Ext.js]], - [Diagnostics.Building_project_0, sources[Project.second][Source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[Project.third][Source.config], relOutputFiles[Project.third][Ext.js]], - [Diagnostics.Building_project_0, sources[Project.third][Source.config]] - ]; + let outFileWithBuildFs: vfs.FileSystem; before(() => { outFileFs = loadProjectFromDisk("tests/projects/outfile-concat"); }); after(() => { outFileFs = undefined!; - initialExpectedDiagnostics = undefined!; + outFileWithBuildFs = undefined!; }); - function createSolutionBuilder(host: fakes.SolutionBuilderHost, baseOptions?: BuildOptions) { - return ts.createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true, ...(baseOptions || {}) }); - } - interface VerifyOutFileScenarioInput { subScenario: string; modifyFs?: (fs: vfs.FileSystem) => void; @@ -98,26 +29,26 @@ namespace ts { baselineOnly, additionalCommandLineArgs, }: VerifyOutFileScenarioInput) { - const incrementalScenarios: TscIncremental[] = []; + const edits: TestTscEdit[] = []; if (!ignoreDtsChanged) { - incrementalScenarios.push({ - buildKind: BuildKind.IncrementalDtsChange, - modifyFs: fs => replaceText(fs, relSources[Project.first][Source.ts][Part.one], "Hello", "Hola"), + edits.push({ + subScenario: "incremental-declaration-changes", + modifyFs: fs => replaceText(fs, "/src/first/first_PART1.ts", "Hello", "Hola"), }); } if (!ignoreDtsUnchanged) { - incrementalScenarios.push({ - buildKind: BuildKind.IncrementalDtsUnchanged, - modifyFs: fs => appendText(fs, relSources[Project.first][Source.ts][Part.one], "console.log(s);"), + edits.push({ + subScenario: "incremental-declaration-doesnt-change", + modifyFs: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"), }); } if (modifyAgainFs) { - incrementalScenarios.push({ - buildKind: BuildKind.IncrementalHeadersChange, + edits.push({ + subScenario: "incremental-headers-change-without-dts-changes", modifyFs: modifyAgainFs }); } - const input: VerifyTsBuildInput = { + const input: VerifyTscWithEditsInput = { subScenario, fs: () => outFileFs, scenario: "outfile-concat", @@ -125,10 +56,10 @@ namespace ts { baselineSourceMap: true, modifyFs, baselineReadFileCalls: !baselineOnly, - incrementalScenarios, + edits, }; - return incrementalScenarios.length ? - verifyTscIncrementalEdits(input) : + return edits.length ? + verifyTscWithEdits(input) : verifyTsc(input); } @@ -146,7 +77,7 @@ namespace ts { // Verify baseline with build info + dts unChanged verifyOutFileScenario({ subScenario: "when final project is not composite but uses project references", - modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, ""), + modifyFs: fs => replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, ""), ignoreDtsChanged: true, baselineOnly: true }); @@ -154,7 +85,7 @@ namespace ts { // Verify baseline with build info verifyOutFileScenario({ subScenario: "when final project is not composite but incremental", - modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, `"incremental": true,`), + modifyFs: fs => replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, `"incremental": true,`), ignoreDtsChanged: true, ignoreDtsUnchanged: true, baselineOnly: true @@ -163,7 +94,7 @@ namespace ts { // Verify baseline with build info verifyOutFileScenario({ subScenario: "when final project specifies tsBuildInfoFile", - modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, `"composite": true, + modifyFs: fs => replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, `"composite": true, "tsBuildInfoFile": "./thirdjs/output/third.tsbuildinfo",`), ignoreDtsChanged: true, ignoreDtsUnchanged: true, @@ -171,20 +102,22 @@ namespace ts { }); function getOutFileFsAfterBuild() { + if (outFileWithBuildFs) return outFileWithBuildFs; const fs = outFileFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host); + const sys = new fakes.System(fs, { executingFilePath: "/lib/tsc" }); + const host = createSolutionBuilderHostForBaseline(sys as TscCompileSystem); + const builder = createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true }); builder.build(); fs.makeReadonly(); - return fs; + return outFileWithBuildFs = fs; } - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "outFile", subScenario: "clean projects", fs: getOutFileFsAfterBuild, commandLineArgs: ["--b", "/src/third", "--clean"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); verifyTsc({ @@ -192,7 +125,7 @@ namespace ts { subScenario: "verify buildInfo absence results in new build", fs: getOutFileFsAfterBuild, commandLineArgs: ["--b", "/src/third", "--verbose"], - modifyFs: fs => fs.unlinkSync(outputFiles[Project.first][Ext.buildinfo]), + modifyFs: fs => fs.unlinkSync("/src/first/bin/first-output.tsbuildinfo"), }); verifyTsc({ @@ -200,100 +133,66 @@ namespace ts { subScenario: "tsbuildinfo is not generated when incremental is set to false", fs: () => outFileFs, commandLineArgs: ["--b", "/src/third", "--verbose"], - modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, ""), + modifyFs: fs => replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, ""), }); - it("rebuilds completely when version in tsbuildinfo doesnt match ts version", () => { - const { fs, tick } = getFsWithTime(outFileFs); - const host = fakes.SolutionBuilderHost.create(fs); - let builder = createSolutionBuilder(host); - builder.build(); - host.assertDiagnosticMessages(...initialExpectedDiagnostics); - host.clearDiagnostics(); - tick(); - builder = createSolutionBuilder(host); - changeCompilerVersion(host); - tick(); - builder.build(); - host.assertDiagnosticMessages( - getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]), - [Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[Project.first][Source.config], fakes.version, version], - [Diagnostics.Building_project_0, sources[Project.first][Source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[Project.second][Source.config], fakes.version, version], - [Diagnostics.Building_project_0, sources[Project.second][Source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[Project.third][Source.config], fakes.version, version], - [Diagnostics.Building_project_0, sources[Project.third][Source.config]], - ); + verifyTscCompileLike(testTscCompileLike, { + scenario: "outFile", + subScenario: "rebuilds completely when version in tsbuildinfo doesnt match ts version", + fs: getOutFileFsAfterBuild, + commandLineArgs: ["--b", "/src/third", "--verbose"], + compile: sys => { + // Buildinfo will have version which does not match with current ts version + const buildHost = createSolutionBuilderHostForBaseline(sys, "FakeTSCurrentVersion"); + const builder = createSolutionBuilder(buildHost, ["/src/third"], { verbose: true }); + sys.exit(builder.build()); + } }); - it("rebuilds completely when command line incremental flag changes between non dts changes", () => { - const { fs, tick } = getFsWithTime(outFileFs); + verifyTscWithEdits({ + scenario: "outFile", + subScenario: "rebuilds completely when command line incremental flag changes between non dts changes", + fs: () => outFileFs, // Make non composite third project - replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, ""); - + modifyFs: fs => replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, ""), // Build with command line incremental - const host = fakes.SolutionBuilderHost.create(fs); - let builder = createSolutionBuilder(host, { incremental: true }); - builder.build(); - host.assertDiagnosticMessages(...initialExpectedDiagnostics); - host.clearDiagnostics(); - tick(); - - // Make non incremental build with change in file that doesnt affect dts - appendText(fs, relSources[Project.first][Source.ts][Part.one], "console.log(s);"); - builder = createSolutionBuilder(host, { verbose: true }); - builder.build(); - host.assertDiagnosticMessages(getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[Project.first][Source.config], relOutputFiles[Project.first][Ext.js], relSources[Project.first][Source.ts][Part.one]], - [Diagnostics.Building_project_0, sources[Project.first][Source.config]], - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[Project.second][Source.config], relSources[Project.second][Source.ts][Part.one], relOutputFiles[Project.second][Ext.js]], - [Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[Project.third][Source.config], "src/first"], - [Diagnostics.Building_project_0, sources[Project.third][Source.config]] - ); - host.clearDiagnostics(); - tick(); - - // Make incremental build with change in file that doesnt affect dts - appendText(fs, relSources[Project.first][Source.ts][Part.one], "console.log(s);"); - builder = createSolutionBuilder(host, { verbose: true, incremental: true }); - builder.build(); - // Builds completely because tsbuildinfo is old. - host.assertDiagnosticMessages( - getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[Project.first][Source.config], relOutputFiles[Project.first][Ext.js], relSources[Project.first][Source.ts][Part.one]], - [Diagnostics.Building_project_0, sources[Project.first][Source.config]], - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[Project.second][Source.config], relSources[Project.second][Source.ts][Part.one], relOutputFiles[Project.second][Ext.js]], - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[Project.third][Source.config], relOutputFiles[Project.third][Ext.buildinfo], "src/first"], - [Diagnostics.Building_project_0, sources[Project.third][Source.config]] - ); - host.clearDiagnostics(); + commandLineArgs: ["--b", "/src/third", "--i", "--verbose"], + edits: [ + { + subScenario: "Make non incremental build with change in file that doesnt affect dts", + modifyFs: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"), + commandLineArgs: ["--b", "/src/third", "--verbose"], + }, + { + subScenario: "Make incremental build with change in file that doesnt affect dts", + modifyFs: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"), + commandLineArgs: ["--b", "/src/third", "--verbose", "--incremental"], + } + ] }); - it("builds till project specified", () => { - const fs = outFileFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, { verbose: false }); - const result = builder.build(sources[Project.second][Source.config]); - host.assertDiagnosticMessages(/*empty*/); - // First and Third is not built - verifyOutputsAbsent(fs, [...outputFiles[Project.first], ...outputFiles[Project.third]]); - // second is built - verifyOutputsPresent(fs, outputFiles[Project.second]); - assert.equal(result, ExitStatus.Success); + verifyTscCompileLike(testTscCompileLike, { + scenario: "outFile", + subScenario: "builds till project specified", + fs: () => outFileFs, + commandLineArgs: ["--build", "/src/second/tsconfig.json"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/third/tsconfig.json"], {}); + sys.exit(builder.build("/src/second/tsconfig.json")); + } }); - it("cleans till project specified", () => { - const fs = outFileFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, { verbose: false }); - builder.build(); - const result = builder.clean(sources[Project.second][Source.config]); - host.assertDiagnosticMessages(/*empty*/); - // First and Third output for present - verifyOutputsPresent(fs, [...outputFiles[Project.first], ...outputFiles[Project.third]]); - // second is cleaned - verifyOutputsAbsent(fs, outputFiles[Project.second]); - assert.equal(result, ExitStatus.Success); + verifyTscCompileLike(testTscCompileLike, { + scenario: "outFile", + subScenario: "cleans till project specified", + fs: getOutFileFsAfterBuild, + commandLineArgs: ["--build", "--clean", "/src/second/tsconfig.json"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/third/tsconfig.json"], { verbose: true }); + sys.exit(builder.clean("/src/second/tsconfig.json")); + } }); describe("Prepend output with .tsbuildinfo", () => { @@ -303,17 +202,17 @@ namespace ts { verifyOutFileScenario({ subScenario: "strict in all projects", modifyFs: fs => { - enableStrict(fs, sources[Project.first][Source.config]); - enableStrict(fs, sources[Project.second][Source.config]); - enableStrict(fs, sources[Project.third][Source.config]); + enableStrict(fs, "/src/first/tsconfig.json"); + enableStrict(fs, "/src/second/tsconfig.json"); + enableStrict(fs, "/src/third/tsconfig.json"); }, - modifyAgainFs: fs => addTestPrologue(fs, relSources[Project.first][Source.ts][Part.one], `"myPrologue"`) + modifyAgainFs: fs => addTestPrologue(fs, "/src/first/first_PART1.ts", `"myPrologue"`) }); // Verify ignore dtsChanged verifyOutFileScenario({ subScenario: "strict in one dependency", - modifyFs: fs => enableStrict(fs, sources[Project.second][Source.config]), + modifyFs: fs => enableStrict(fs, "/src/second/tsconfig.json"), modifyAgainFs: fs => addTestPrologue(fs, "src/first/first_PART1.ts", `"myPrologue"`), ignoreDtsChanged: true, baselineOnly: true @@ -323,28 +222,28 @@ namespace ts { verifyOutFileScenario({ subScenario: "multiple prologues in all projects", modifyFs: fs => { - enableStrict(fs, sources[Project.first][Source.config]); - addTestPrologue(fs, sources[Project.first][Source.ts][Part.one], `"myPrologue"`); - enableStrict(fs, sources[Project.second][Source.config]); - addTestPrologue(fs, sources[Project.second][Source.ts][Part.one], `"myPrologue"`); - addTestPrologue(fs, sources[Project.second][Source.ts][Part.two], `"myPrologue2";`); - enableStrict(fs, sources[Project.third][Source.config]); - addTestPrologue(fs, sources[Project.third][Source.ts][Part.one], `"myPrologue";`); - addTestPrologue(fs, sources[Project.third][Source.ts][Part.one], `"myPrologue3";`); + enableStrict(fs, "/src/first/tsconfig.json"); + addTestPrologue(fs, "/src/first/first_PART1.ts", `"myPrologue"`); + enableStrict(fs, "/src/second/tsconfig.json"); + addTestPrologue(fs, "/src/second/second_part1.ts", `"myPrologue"`); + addTestPrologue(fs, "/src/second/second_part2.ts", `"myPrologue2";`); + enableStrict(fs, "/src/third/tsconfig.json"); + addTestPrologue(fs, "/src/third/third_part1.ts", `"myPrologue";`); + addTestPrologue(fs, "/src/third/third_part1.ts", `"myPrologue3";`); }, - modifyAgainFs: fs => addTestPrologue(fs, relSources[Project.first][Source.ts][Part.one], `"myPrologue5"`) + modifyAgainFs: fs => addTestPrologue(fs, "/src/first/first_PART1.ts", `"myPrologue5"`) }); // Verify ignore dtsChanged verifyOutFileScenario({ subScenario: "multiple prologues in different projects", modifyFs: fs => { - enableStrict(fs, sources[Project.first][Source.config]); - addTestPrologue(fs, sources[Project.second][Source.ts][Part.one], `"myPrologue"`); - addTestPrologue(fs, sources[Project.second][Source.ts][Part.two], `"myPrologue2";`); - enableStrict(fs, sources[Project.third][Source.config]); + enableStrict(fs, "/src/first/tsconfig.json"); + addTestPrologue(fs, "/src/second/second_part1.ts", `"myPrologue"`); + addTestPrologue(fs, "/src/second/second_part2.ts", `"myPrologue2";`); + enableStrict(fs, "/src/third/tsconfig.json"); }, - modifyAgainFs: fs => addTestPrologue(fs, sources[Project.first][Source.ts][Part.one], `"myPrologue5"`), + modifyAgainFs: fs => addTestPrologue(fs, "/src/first/first_PART1.ts", `"myPrologue5"`), ignoreDtsChanged: true, baselineOnly: true }); @@ -456,13 +355,13 @@ namespace ts { } function diableRemoveCommentsInAll(fs: vfs.FileSystem) { - disableRemoveComments(fs, sources[Project.first][Source.config]); - disableRemoveComments(fs, sources[Project.second][Source.config]); - disableRemoveComments(fs, sources[Project.third][Source.config]); + disableRemoveComments(fs, "/src/first/tsconfig.json"); + disableRemoveComments(fs, "/src/second/tsconfig.json"); + disableRemoveComments(fs, "/src/third/tsconfig.json"); } function stripInternalOfThird(fs: vfs.FileSystem) { - replaceText(fs, sources[Project.third][Source.config], `"declaration": true,`, `"declaration": true, + replaceText(fs, "/src/third/tsconfig.json", `"declaration": true,`, `"declaration": true, "stripInternal": true,`); } @@ -472,8 +371,8 @@ namespace ts { diableRemoveCommentsInAll(fs); } stripInternalOfThird(fs); - replaceText(fs, sources[Project.first][Source.ts][Part.one], "interface", `${internal} interface`); - appendText(fs, sources[Project.second][Source.ts][Part.one], ` + replaceText(fs, "/src/first/first_PART1.ts", "interface", `${internal} interface`); + appendText(fs, "/src/second/second_part1.ts", ` class normalC { ${internal} constructor() { } ${internal} prop: string; @@ -505,14 +404,14 @@ ${internal} enum internalEnum { a, b, c }`); verifyOutFileScenario({ subScenario: "stripInternal", modifyFs: stripInternalScenario, - modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"), + modifyAgainFs: fs => replaceText(fs, "/src/first/first_PART1.ts", `/*@internal*/ interface`, "interface"), }); // Verify ignore dtsChanged verifyOutFileScenario({ subScenario: "stripInternal with comments emit enabled", modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true), - modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"), + modifyAgainFs: fs => replaceText(fs, "/src/first/first_PART1.ts", `/*@internal*/ interface`, "interface"), ignoreDtsChanged: true, baselineOnly: true }); @@ -521,7 +420,7 @@ ${internal} enum internalEnum { a, b, c }`); verifyOutFileScenario({ subScenario: "stripInternal jsdoc style comment", modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), - modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/**@internal*/ interface`, "interface"), + modifyAgainFs: fs => replaceText(fs, "/src/first/first_PART1.ts", `/**@internal*/ interface`, "interface"), ignoreDtsChanged: true, baselineOnly: true }); @@ -536,9 +435,9 @@ ${internal} enum internalEnum { a, b, c }`); describe("with three levels of project dependency", () => { function makeOneTwoThreeDependOrder(fs: vfs.FileSystem) { - replaceText(fs, sources[Project.second][Source.config], "[", `[ + replaceText(fs, "/src/second/tsconfig.json", "[", `[ { "path": "../first", "prepend": true }`); - replaceText(fs, sources[Project.third][Source.config], `{ "path": "../first", "prepend": true },`, ""); + replaceText(fs, "/src/third/tsconfig.json", `{ "path": "../first", "prepend": true },`, ""); } function stripInternalWithDependentOrder(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) { @@ -550,14 +449,14 @@ ${internal} enum internalEnum { a, b, c }`); verifyOutFileScenario({ subScenario: "stripInternal when one-two-three are prepended in order", modifyFs: stripInternalWithDependentOrder, - modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"), + modifyAgainFs: fs => replaceText(fs, "/src/first/first_PART1.ts", `/*@internal*/ interface`, "interface"), }); // Verify ignore dtsChanged verifyOutFileScenario({ subScenario: "stripInternal with comments emit enabled when one-two-three are prepended in order", modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true), - modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"), + modifyAgainFs: fs => replaceText(fs, "/src/first/first_PART1.ts", `/*@internal*/ interface`, "interface"), ignoreDtsChanged: true, baselineOnly: true }); @@ -566,7 +465,7 @@ ${internal} enum internalEnum { a, b, c }`); verifyOutFileScenario({ subScenario: "stripInternal jsdoc style comment when one-two-three are prepended in order", modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), - modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/**@internal*/ interface`, "interface"), + modifyAgainFs: fs => replaceText(fs, "/src/first/first_PART1.ts", `/**@internal*/ interface`, "interface"), ignoreDtsChanged: true, baselineOnly: true }); @@ -585,7 +484,7 @@ ${internal} enum internalEnum { a, b, c }`); subScenario: "stripInternal baseline when internal is inside another internal", modifyFs: fs => { stripInternalOfThird(fs); - prependText(fs, sources[Project.first][Source.ts][Part.one], `namespace ts { + prependText(fs, "/src/first/first_PART1.ts", `namespace ts { /* @internal */ /** * Subset of properties from SourceFile that are used in multiple utility functions @@ -624,7 +523,7 @@ ${internal} enum internalEnum { a, b, c }`); subScenario: "stripInternal when few members of enum are internal", modifyFs: fs => { stripInternalOfThird(fs); - prependText(fs, sources[Project.first][Source.ts][Part.one], `enum TokenFlags { + prependText(fs, "/src/first/first_PART1.ts", `enum TokenFlags { None = 0, /* @internal */ PrecedingLineBreak = 1 << 0, @@ -659,9 +558,9 @@ ${internal} enum internalEnum { a, b, c }`); ignoreDtsChanged: true, ignoreDtsUnchanged: true, modifyFs: fs => { - fs.writeFileSync(sources[Project.first][Source.ts][Part.one], "/* @internal */ const A = 1;"); - fs.writeFileSync(sources[Project.third][Source.ts][Part.one], "const B = 2;"); - fs.writeFileSync(sources[Project.first][Source.config], JSON.stringify({ + fs.writeFileSync("/src/first/first_PART1.ts", "/* @internal */ const A = 1;"); + fs.writeFileSync("/src/third/third_part1.ts", "const B = 2;"); + fs.writeFileSync("/src/first/tsconfig.json", JSON.stringify({ compilerOptions: { composite: true, declaration: true, @@ -670,9 +569,9 @@ ${internal} enum internalEnum { a, b, c }`); sourceMap: true, outFile: "./bin/first-output.js" }, - files: [sources[Project.first][Source.ts][Part.one]] + files: ["/src/first/first_PART1.ts"] })); - fs.writeFileSync(sources[Project.third][Source.config], JSON.stringify({ + fs.writeFileSync("/src/third/tsconfig.json", JSON.stringify({ compilerOptions: { composite: true, declaration: true, @@ -682,7 +581,7 @@ ${internal} enum internalEnum { a, b, c }`); outFile: "./thirdjs/output/third-output.js", }, references: [{ path: "../first", prepend: true }], - files: [sources[Project.third][Source.ts][Part.one]] + files: ["/src/third/third_part1.ts"] })); } }); @@ -690,7 +589,7 @@ ${internal} enum internalEnum { a, b, c }`); describe("empty source files", () => { function makeThirdEmptySourceFile(fs: vfs.FileSystem) { - fs.writeFileSync(sources[Project.third][Source.ts][Part.one], "", "utf8"); + fs.writeFileSync("/src/third/third_part1.ts", "", "utf8"); } // Verify ignore dtsChanged @@ -706,9 +605,9 @@ ${internal} enum internalEnum { a, b, c }`); subScenario: "declarationMap and sourceMap disabled", modifyFs: fs => { makeThirdEmptySourceFile(fs); - replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, ""); - replaceText(fs, sources[Project.third][Source.config], `"sourceMap": true,`, ""); - replaceText(fs, sources[Project.third][Source.config], `"declarationMap": true,`, ""); + replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, ""); + replaceText(fs, "/src/third/tsconfig.json", `"sourceMap": true,`, ""); + replaceText(fs, "/src/third/tsconfig.json", `"declarationMap": true,`, ""); }, ignoreDtsChanged: true, ignoreDtsUnchanged: true, @@ -724,18 +623,18 @@ ${internal} enum internalEnum { a, b, c }`); commandLineArgs: ["--b", "/src/third", "--verbose"], modifyFs: fs => { // No prepend - replaceText(fs, sources[Project.third][Source.config], `{ "path": "../first", "prepend": true }`, `{ "path": "../first" }`); - replaceText(fs, sources[Project.third][Source.config], `{ "path": "../second", "prepend": true }`, `{ "path": "../second" }`); + replaceText(fs, "/src/third/tsconfig.json", `{ "path": "../first", "prepend": true }`, `{ "path": "../first" }`); + replaceText(fs, "/src/third/tsconfig.json", `{ "path": "../second", "prepend": true }`, `{ "path": "../second" }`); // Non Modules - replaceText(fs, sources[Project.first][Source.config], `"composite": true,`, `"composite": true, "module": "none",`); - replaceText(fs, sources[Project.second][Source.config], `"composite": true,`, `"composite": true, "module": "none",`); - replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, `"composite": true, "module": "none",`); + replaceText(fs, "/src/first/tsconfig.json", `"composite": true,`, `"composite": true, "module": "none",`); + replaceText(fs, "/src/second/tsconfig.json", `"composite": true,`, `"composite": true, "module": "none",`); + replaceText(fs, "/src/third/tsconfig.json", `"composite": true,`, `"composite": true, "module": "none",`); // Own file emit - replaceText(fs, sources[Project.first][Source.config], `"outFile": "./bin/first-output.js",`, ""); - replaceText(fs, sources[Project.second][Source.config], `"outFile": "../2/second-output.js",`, ""); - replaceText(fs, sources[Project.third][Source.config], `"outFile": "./thirdjs/output/third-output.js",`, ""); + replaceText(fs, "/src/first/tsconfig.json", `"outFile": "./bin/first-output.js",`, ""); + replaceText(fs, "/src/second/tsconfig.json", `"outFile": "../2/second-output.js",`, ""); + replaceText(fs, "/src/third/tsconfig.json", `"outFile": "./thirdjs/output/third-output.js",`, ""); }, }); }); diff --git a/src/testRunner/unittests/tsbuild/outputPaths.ts b/src/testRunner/unittests/tsbuild/outputPaths.ts index e2a9ac549bf0a..72374f846115f 100644 --- a/src/testRunner/unittests/tsbuild/outputPaths.ts +++ b/src/testRunner/unittests/tsbuild/outputPaths.ts @@ -1,18 +1,17 @@ namespace ts { describe("unittests:: tsbuild - output file paths", () => { - const noChangeProject: TscIncremental = { - buildKind: BuildKind.NoChangeRun, + const noChangeProject: TestTscEdit = { modifyFs: noop, subScenario: "Normal build without change, that does not block emit on error to show files that get emitted", commandLineArgs: ["-p", "/src/tsconfig.json"], }; - const incrementalScenarios: TscIncremental[] = [ + const edits: TestTscEdit[] = [ noChangeRun, noChangeProject, ]; - function verify(input: Pick, expectedOuptutNames: readonly string[]) { - verifyTscSerializedIncrementalEdits({ + function verify(input: Pick, expectedOuptutNames: readonly string[]) { + verifyTscWithEdits({ scenario: "outputPaths", commandLineArgs: ["--b", "/src/tsconfig.json", "-v"], ...input @@ -42,7 +41,7 @@ namespace ts { } }) }), - incrementalScenarios, + edits, }, ["/src/dist/index.js"]); verify({ @@ -56,16 +55,7 @@ namespace ts { } }) }), - incrementalScenarios: [ - noChangeRun, - { - ...noChangeProject, - cleanBuildDiscrepancies: () => new Map([ - ["/src/dist/tsconfig.tsbuildinfo", CleanBuildDescrepancy.CleanFileTextDifferent], // tsbuildinfo will have -p setting when built using -p vs no build happens incrementally because of no change. - ["/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt", CleanBuildDescrepancy.CleanFileTextDifferent] // tsbuildinfo will have -p setting when built using -p vs no build happens incrementally because of no change. - ]), - } - ], + edits, }, ["/src/dist/src/index.js", "/src/dist/src/index.d.ts"]); verify({ @@ -79,7 +69,7 @@ namespace ts { } }) }), - incrementalScenarios, + edits, }, ["/src/dist/index.js"]); verify({ @@ -94,7 +84,7 @@ namespace ts { } }) }), - incrementalScenarios, + edits, }, ["/src/dist/index.js"]); verify({ @@ -110,7 +100,7 @@ namespace ts { } }) }), - incrementalScenarios, + edits, }, ["/src/dist/index.js", "/src/dist/index.d.ts"]); }); } diff --git a/src/testRunner/unittests/tsbuild/publicApi.ts b/src/testRunner/unittests/tsbuild/publicApi.ts index 4b9d5ae5b6060..cb2d35ca9670f 100644 --- a/src/testRunner/unittests/tsbuild/publicApi.ts +++ b/src/testRunner/unittests/tsbuild/publicApi.ts @@ -2,7 +2,7 @@ namespace ts { describe("unittests:: tsbuild:: Public API with custom transformers when passed to build", () => { let sys: TscCompileSystem; before(() => { - const initialFs = getFsWithTime(loadProjectFromFiles({ + const inputFs = loadProjectFromFiles({ "/src/tsconfig.json": JSON.stringify({ references: [ { path: "./shared/tsconfig.json" }, @@ -29,9 +29,7 @@ export class c2 { } export enum e2 { } // leading export function f22() { } // trailing`, - })).fs.makeReadonly(); - const inputFs = initialFs.shadow(); - inputFs.makeReadonly(); + }).makeReadonly(); const fs = inputFs.shadow(); // Create system @@ -48,7 +46,7 @@ export function f22() { } // trailing`, writtenFiles.add(path); return originalWriteFile.call(sys, fileName, content, writeByteOrderMark); }; - const { cb, getPrograms } = commandLineCallbacks(sys, /*originalReadCall*/ undefined, originalWriteFile); + const { cb, getPrograms } = commandLineCallbacks(sys, /*originalReadCall*/ undefined); const buildHost = createSolutionBuilderHost( sys, /*createProgram*/ undefined, @@ -70,7 +68,7 @@ export function f22() { } // trailing`, const baseFsPatch = inputFs.diff(/*base*/ undefined, { baseIsNotShadowRoot: true }); const patch = fs.diff(inputFs, { includeChangedFileWithSameContent: true }); return { - file: `tsbuild/$publicAPI/${BuildKind.Initial}/${"build with custom transformers".split(" ").join("-")}.js`, + file: `tsbuild/publicAPI/build-with-custom-transformers.js`, text: `Input:: ${baseFsPatch ? vfs.formatPatch(baseFsPatch) : ""} diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index 733f61efe3f3f..834d5825377f2 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -51,32 +51,32 @@ export default hello.hello`); commandLineArgs: ["--b", "/src/tsconfig_withIncludeAndFiles.json", "--v", "--explainFiles"], }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "resolveJsonModule", subScenario: "sourcemap", fs: () => projFs, commandLineArgs: ["--b", "src/tsconfig_withFiles.json", "--verbose", "--explainFiles"], modifyFs: fs => replaceText(fs, "src/tsconfig_withFiles.json", `"composite": true,`, `"composite": true, "sourceMap": true,`), - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "resolveJsonModule", subScenario: "without outDir", fs: () => projFs, commandLineArgs: ["--b", "src/tsconfig_withFiles.json", "--verbose"], modifyFs: fs => replaceText(fs, "src/tsconfig_withFiles.json", `"outDir": "dist",`, ""), - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); }); describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "resolveJsonModule", subScenario: "importing json module from project reference", fs: () => loadProjectFromDisk("tests/projects/importJsonFromProjectReference"), commandLineArgs: ["--b", "src/tsconfig.json", "--verbose", "--explainFiles"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); }); } diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index d666370d156f6..2178c422ab9ea 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -1,26 +1,32 @@ namespace ts { describe("unittests:: tsbuild:: on 'sample1' project", () => { let projFs: vfs.FileSystem; - const testsOutputs = ["/src/tests/index.js", "/src/tests/index.d.ts", "/src/tests/tsconfig.tsbuildinfo"]; - const logicOutputs = ["/src/logic/index.js", "/src/logic/index.js.map", "/src/logic/index.d.ts", "/src/logic/tsconfig.tsbuildinfo"]; - const coreOutputs = ["/src/core/index.js", "/src/core/index.d.ts", "/src/core/index.d.ts.map", "/src/core/tsconfig.tsbuildinfo"]; - const allExpectedOutputs = [...testsOutputs, ...logicOutputs, ...coreOutputs]; - + let projFsWithBuild: vfs.FileSystem; before(() => { projFs = loadProjectFromDisk("tests/projects/sample1"); }); after(() => { projFs = undefined!; // Release the contents + projFsWithBuild = undefined!; }); + function getTsBuildProjectFile(project: string, file: string): tscWatch.File { + return { + path: TestFSWithWatch.getTsBuildProjectFilePath(project, file), + content: projFs.readFileSync(`/src/${project}/${file}`, "utf8")! + }; + } + function getSampleFsAfterBuild() { + if (projFsWithBuild) return projFsWithBuild; const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); + const sys = new fakes.System(fs, { executingFilePath: "/lib/tsc" }); + const host = createSolutionBuilderHostForBaseline(sys as TscCompileSystem); const builder = createSolutionBuilder(host, ["/src/tests"], {}); builder.build(); fs.makeReadonly(); - return fs; + return projFsWithBuild = fs; } describe("sanity check of clean build of 'sample1' project", () => { @@ -65,143 +71,121 @@ namespace ts { }); describe("clean builds", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "sample1", subScenario: "removes all files it built", fs: getSampleFsAfterBuild, commandLineArgs: ["--b", "/src/tests", "--clean"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); - it("cleans till project specified", () => { - const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], {}); - builder.build(); - const result = builder.clean("/src/logic"); - host.assertDiagnosticMessages(/*empty*/); - verifyOutputsPresent(fs, testsOutputs); - verifyOutputsAbsent(fs, [...logicOutputs, ...coreOutputs]); - assert.equal(result, ExitStatus.Success); + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "cleans till project specified", + fs: getSampleFsAfterBuild, + commandLineArgs: ["--b", "/src/logic", "--clean"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/third/tsconfig.json"], {}); + sys.exit(builder.clean("/src/logic")); + } }); - it("cleaning project in not build order doesnt throw error", () => { - const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], {}); - builder.build(); - const result = builder.clean("/src/logic2"); - host.assertDiagnosticMessages(/*empty*/); - verifyOutputsPresent(fs, allExpectedOutputs); - assert.equal(result, ExitStatus.InvalidProject_OutputsSkipped); + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "cleaning project in not build order doesnt throw error", + fs: getSampleFsAfterBuild, + commandLineArgs: ["--b", "/src/logic2", "--clean"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/third/tsconfig.json"], {}); + sys.exit(builder.clean("/src/logic2")); + } }); }); describe("force builds", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "sample1", subScenario: "always builds under with force option", fs: () => projFs, commandLineArgs: ["--b", "/src/tests", "--force"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); }); describe("can detect when and what to rebuild", () => { - function initializeWithBuild(opts?: BuildOptions) { - const { fs, tick } = getFsWithTime(projFs); - const host = fakes.SolutionBuilderHost.create(fs); - let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); - builder.build(); - host.clearDiagnostics(); - tick(); - builder = createSolutionBuilder(host, ["/src/tests"], { ...(opts || {}), verbose: true }); - return { fs, host, builder }; - } - - verifyTscIncrementalEdits({ + verifyTscWithEdits({ scenario: "sample1", subScenario: "can detect when and what to rebuild", fs: getSampleFsAfterBuild, commandLineArgs: ["--b", "/src/tests", "--verbose"], - incrementalScenarios: [ + edits: [ // Update a file in the leaf node (tests), only it should rebuild the last one { subScenario: "Only builds the leaf node project", - buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => fs.writeFileSync("/src/tests/index.ts", "const m = 10;"), }, // Update a file in the parent (without affecting types), should get fast downstream builds { subScenario: "Detects type-only changes in upstream projects", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/core/index.ts", "HELLO WORLD", "WELCOME PLANET"), }, - { - subScenario: "indicates that it would skip builds during a dry build", - buildKind: BuildKind.IncrementalDtsUnchanged, - modifyFs: noop, - commandLineArgs: ["--b", "/src/tests", "--dry"], - }, - { - subScenario: "rebuilds from start if force option is set", - buildKind: BuildKind.IncrementalDtsChange, - modifyFs: noop, - commandLineArgs: ["--b", "/src/tests", "--verbose", "--force"], - }, { subScenario: "rebuilds when tsconfig changes", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es3"`), }, ] }); - it("rebuilds completely when version in tsbuildinfo doesnt match ts version", () => { - const { host, builder } = initializeWithBuild(); - changeCompilerVersion(host); - builder.build(); - host.assertDiagnosticMessages( - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, "src/core/tsconfig.json", fakes.version, version], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], - [Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, "src/logic/tsconfig.json", fakes.version, version], - [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], - [Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, "src/tests/tsconfig.json", fakes.version, version], - [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - ); + verifyTsc({ + scenario: "sample1", + subScenario: "indicates that it would skip builds during a dry build", + fs: getSampleFsAfterBuild, + commandLineArgs: ["--b", "/src/tests", "--dry"], }); - it("does not rebuild if there is no program and bundle in the ts build info event if version doesnt match ts version", () => { - const { fs, tick } = getFsWithTime(projFs); - const host = fakes.SolutionBuilderHost.create(fs, /*options*/ undefined, /*setParentNodes*/ undefined, createAbstractBuilder); - let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); - builder.build(); - host.assertDiagnosticMessages( - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"], - [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"], - [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"] - ); - verifyOutputsPresent(fs, allExpectedOutputs); + verifyTsc({ + scenario: "sample1", + subScenario: "rebuilds from start if force option is set", + fs: getSampleFsAfterBuild, + commandLineArgs: ["--b", "/src/tests", "--verbose", "--force"], + }); - host.clearDiagnostics(); - tick(); - builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); - changeCompilerVersion(host); - builder.build(); - host.assertDiagnosticMessages( - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"], - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"], - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/tests/tsconfig.json", "src/tests/index.ts", "src/tests/index.js"] - ); + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "rebuilds completely when version in tsbuildinfo doesnt match ts version", + fs: getSampleFsAfterBuild, + commandLineArgs: ["--b", "/src/tests", "--verbose"], + compile: sys => { + // Buildinfo will have version which does not match with current ts version + const buildHost = createSolutionBuilderHostForBaseline(sys, "FakeTSCurrentVersion"); + const builder = createSolutionBuilder(buildHost, ["/src/tests"], { verbose: true }); + sys.exit(builder.build()); + } }); - verifyTscSerializedIncrementalEdits({ + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "does not rebuild if there is no program and bundle in the ts build info event if version doesnt match ts version", + fs: () => { + const fs = projFs.shadow(); + const host = fakes.SolutionBuilderHost.create(fs, /*options*/ undefined, /*setParentNodes*/ undefined, createAbstractBuilder); + const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); + builder.build(); + fs.makeReadonly(); + return fs; + }, + commandLineArgs: ["--b", "/src/tests", "--verbose"], + compile: sys => { + // Buildinfo will have version which does not match with current ts version + const buildHost = createSolutionBuilderHostForBaseline(sys, "FakeTSCurrentVersion"); + const builder = createSolutionBuilder(buildHost, ["/src/tests"], { verbose: true }); + sys.exit(builder.build()); + }, + }); + + verifyTscWithEdits({ scenario: "sample1", subScenario: "rebuilds when extended config file changes", fs: () => projFs, @@ -210,86 +194,93 @@ namespace ts { fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: { target: "es3" } })); replaceText(fs, "/src/tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`); }, - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsChange, + edits: [{ + subScenario: "incremental-declaration-changes", modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} })) }] }); - it("builds till project specified", () => { - const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], {}); - const result = builder.build("/src/logic"); - host.assertDiagnosticMessages(/*empty*/); - verifyOutputsAbsent(fs, testsOutputs); - verifyOutputsPresent(fs, [...logicOutputs, ...coreOutputs]); - assert.equal(result, ExitStatus.Success); + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "builds till project specified", + fs: () => projFs, + commandLineArgs: ["--build", "/src/logic/tsconfig.json"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/tests"], {}); + sys.exit(builder.build("/src/logic/tsconfig.json")); + } }); - it("building project in not build order doesnt throw error", () => { - const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], {}); - const result = builder.build("/src/logic2"); - host.assertDiagnosticMessages(/*empty*/); - verifyOutputsAbsent(fs, allExpectedOutputs); - assert.equal(result, ExitStatus.InvalidProject_OutputsSkipped); + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "building project in not build order doesnt throw error", + fs: () => projFs, + commandLineArgs: ["--build", "/src/logic2/tsconfig.json"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/tests"], {}); + sys.exit(builder.build("/src/logic2/tsconfig.json")); + } }); it("building using getNextInvalidatedProject", () => { - interface SolutionBuilderResult { - project: ResolvedConfigFileName; - result: T; - } + const coreConfig = getTsBuildProjectFile("core", "tsconfig.json"); + const coreIndex = getTsBuildProjectFile("core", "index.ts"); + const coreDecl = getTsBuildProjectFile("core", "some_decl.d.ts"); + const coreAnotherModule = getTsBuildProjectFile("core", "anotherModule.ts"); + const logicConfig = getTsBuildProjectFile("logic", "tsconfig.json"); + const logicIndex = getTsBuildProjectFile("logic", "index.ts"); + const testsConfig = getTsBuildProjectFile("tests", "tsconfig.json"); + const testsIndex = getTsBuildProjectFile("tests", "index.ts"); + const baseline: string[] = []; + let oldSnap: ReturnType | undefined; + const system = TestFSWithWatch.changeToHostTrackingWrittenFiles( + fakes.patchHostForBuildInfoReadWrite( + tscWatch.createWatchedSystem([ + coreConfig, coreIndex, coreDecl, coreAnotherModule, + logicConfig, logicIndex, + testsConfig, testsIndex, + tscWatch.libFile + ]) + ) + ); - const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], {}); - verifyBuildNextResult({ - project: "/src/core/tsconfig.json" as ResolvedConfigFileName, - result: ExitStatus.Success - }, coreOutputs, [...logicOutputs, ...testsOutputs]); - - verifyBuildNextResult({ - project: "/src/logic/tsconfig.json" as ResolvedConfigFileName, - result: ExitStatus.Success - }, [...coreOutputs, ...logicOutputs], testsOutputs); - - verifyBuildNextResult({ - project: "/src/tests/tsconfig.json" as ResolvedConfigFileName, - result: ExitStatus.Success - }, allExpectedOutputs, emptyArray); - - verifyBuildNextResult(/*expected*/ undefined, allExpectedOutputs, emptyArray); - - function verifyBuildNextResult( - expected: SolutionBuilderResult | undefined, - presentOutputs: readonly string[], - absentOutputs: readonly string[] - ) { + const host = createSolutionBuilderHostForBaseline(system); + const builder = createSolutionBuilder(host, [testsConfig.path], {}); + baseline.push("Input::"); + baselineState(); + verifyBuildNextResult(); // core + verifyBuildNextResult(); // logic + verifyBuildNextResult();// tests + verifyBuildNextResult(); // All Done + Harness.Baseline.runBaseline(`tsbuild/sample1/building-using-getNextInvalidatedProject.js`, baseline.join("\r\n")); + + function verifyBuildNextResult() { const project = builder.getNextInvalidatedProject(); const result = project && project.done(); - assert.deepEqual(project && { project: project.project, result }, expected); - verifyOutputsPresent(fs, presentOutputs); - verifyOutputsAbsent(fs, absentOutputs); + baseline.push(`Project Result:: ${JSON.stringify({ project: project?.project, result })}`); + baselineState(); + } + + function baselineState() { + system.serializeOutput(baseline); + system.diff(baseline, oldSnap); + system.writtenFiles.clear(); + oldSnap = system.snap(); } }); - it("building using buildReferencedProject", () => { - const fs = projFs.shadow(); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); - builder.buildReferences("/src/tests"); - host.assertDiagnosticMessages( - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"], - [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], - ); - verifyOutputsPresent(fs, [...coreOutputs, ...logicOutputs]); - verifyOutputsAbsent(fs, testsOutputs); + verifyTscCompileLike(testTscCompileLike, { + scenario: "sample1", + subScenario: "building using buildReferencedProject", + fs: () => projFs, + commandLineArgs: ["--build", "/src/logic2/tsconfig.json"], + compile: sys => { + const buildHost = createSolutionBuilderHostForBaseline(sys); + const builder = createSolutionBuilder(buildHost, ["/src/tests"], { verbose: true }); + sys.exit(builder.buildReferences("/src/tests")); + } }); }); @@ -305,109 +296,115 @@ namespace ts { describe("project invalidation", () => { it("invalidates projects correctly", () => { - const { fs, time, tick } = getFsWithTime(projFs); - const host = fakes.SolutionBuilderHost.create(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: false }); + const coreConfig = getTsBuildProjectFile("core", "tsconfig.json"); + const coreIndex = getTsBuildProjectFile("core", "index.ts"); + const coreDecl = getTsBuildProjectFile("core", "some_decl.d.ts"); + const coreAnotherModule = getTsBuildProjectFile("core", "anotherModule.ts"); + const logicConfig = getTsBuildProjectFile("logic", "tsconfig.json"); + const logicIndex = getTsBuildProjectFile("logic", "index.ts"); + const testsConfig = getTsBuildProjectFile("tests", "tsconfig.json"); + const testsIndex = getTsBuildProjectFile("tests", "index.ts"); + const baseline: string[] = []; + let oldSnap: ReturnType | undefined; + const system = TestFSWithWatch.changeToHostTrackingWrittenFiles( + fakes.patchHostForBuildInfoReadWrite( + tscWatch.createWatchedSystem([ + coreConfig, coreIndex, coreDecl, coreAnotherModule, + logicConfig, logicIndex, + testsConfig, testsIndex, + tscWatch.libFile + ]) + ) + ); + const host = createSolutionBuilderHostForBaseline(system); + const builder = createSolutionBuilder(host, [testsConfig.path], { dry: false, force: false, verbose: false }); builder.build(); - host.assertDiagnosticMessages(/*empty*/); + baselineState("Build of project"); // Update a timestamp in the middle project - tick(); - appendText(fs, "/src/logic/index.ts", "function foo() {}"); - const originalWriteFile = fs.writeFileSync; - const writtenFiles = new Map(); - fs.writeFileSync = (path, data, encoding) => { - writtenFiles.set(path, true); - originalWriteFile.call(fs, path, data, encoding); - }; + system.appendFile(logicIndex.path, "function foo() {}"); + // Because we haven't reset the build context, the builder should assume there's nothing to do right now - const status = builder.getUpToDateStatusOfProject("/src/logic"); - assert.equal(status.type, UpToDateStatusType.UpToDate, "Project should be assumed to be up-to-date"); - verifyInvalidation(/*expectedToWriteTests*/ false); + const status = builder.getUpToDateStatusOfProject(logicConfig.path); + baseline.push(`Project should still be upto date: ${UpToDateStatusType[status.type]}`); + verifyInvalidation("non Dts change to logic"); // Rebuild this project - fs.writeFileSync("/src/logic/index.ts", `${fs.readFileSync("/src/logic/index.ts")} -export class cNew {}`); - verifyInvalidation(/*expectedToWriteTests*/ true); + system.appendFile(logicIndex.path, `export class cNew {}`); + verifyInvalidation("Dts change to Logic"); + Harness.Baseline.runBaseline(`tsbuild/sample1/invalidates-projects-correctly.js`, baseline.join("\r\n")); - function verifyInvalidation(expectedToWriteTests: boolean) { + function verifyInvalidation(heading: string) { // Rebuild this project - tick(); - builder.invalidateProject("/src/logic/tsconfig.json" as ResolvedConfigFilePath); + builder.invalidateProject(logicConfig.path as ResolvedConfigFilePath); builder.buildNextInvalidatedProject(); - // The file should be updated - assert.isTrue(writtenFiles.has("/src/logic/index.js"), "JS file should have been rebuilt"); - assert.equal(fs.statSync("/src/logic/index.js").mtimeMs, time(), "JS file should have been rebuilt"); - assert.isFalse(writtenFiles.has("/src/tests/index.js"), "Downstream JS file should *not* have been rebuilt"); - assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should *not* have been rebuilt"); - writtenFiles.clear(); + baselineState(`${heading}:: After rebuilding logicConfig`); // Build downstream projects should update 'tests', but not 'core' - tick(); builder.buildNextInvalidatedProject(); - if (expectedToWriteTests) { - assert.isTrue(writtenFiles.has("/src/tests/index.js"), "Downstream JS file should have been rebuilt"); - } - else { - assert.equal(writtenFiles.size, 0, "Should not write any new files"); - } - assert.equal(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have new timestamp"); - assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt"); + baselineState(`${heading}:: After building next project`); + } + + function baselineState(heading: string) { + baseline.push(heading); + system.serializeOutput(baseline); + system.diff(baseline, oldSnap); + system.writtenFiles.clear(); + oldSnap = system.snap(); } }); }); - const coreChanges: TscIncremental[] = [ + const coreChanges: TestTscEdit[] = [ { - buildKind: BuildKind.IncrementalDtsChange, + subScenario: "incremental-declaration-changes", modifyFs: fs => appendText(fs, "/src/core/index.ts", ` export class someClass { }`), }, { - buildKind: BuildKind.IncrementalDtsUnchanged, + subScenario: "incremental-declaration-doesnt-change", modifyFs: fs => appendText(fs, "/src/core/index.ts", ` class someClass2 { }`), } ]; describe("lists files", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "sample1", subScenario: "listFiles", fs: () => projFs, commandLineArgs: ["--b", "/src/tests", "--listFiles"], - incrementalScenarios: coreChanges + edits: coreChanges }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "sample1", subScenario: "listEmittedFiles", fs: () => projFs, commandLineArgs: ["--b", "/src/tests", "--listEmittedFiles"], - incrementalScenarios: coreChanges + edits: coreChanges }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "sample1", subScenario: "explainFiles", fs: () => projFs, commandLineArgs: ["--b", "/src/tests", "--explainFiles", "--v"], - incrementalScenarios: coreChanges + edits: coreChanges }); }); describe("emit output", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "sample", fs: () => projFs, scenario: "sample1", commandLineArgs: ["--b", "/src/tests", "--verbose"], baselineSourceMap: true, baselineReadFileCalls: true, - incrementalScenarios: [ + edits: [ ...coreChanges, { subScenario: "when logic config changes declaration dir", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"declaration": true,`, `"declaration": true, "declarationDir": "decls",`), }, @@ -426,7 +423,7 @@ class someClass2 { }`), baselineReadFileCalls: true }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "when declaration option changes", fs: () => projFs, scenario: "sample1", @@ -437,13 +434,13 @@ class someClass2 { }`), "skipDefaultLibCheck": true } }`), - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsChange, + edits: [{ + subScenario: "incremental-declaration-changes", modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"incremental": true,`, `"incremental": true, "declaration": true,`), }], }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "when target option changes", fs: () => projFs, scenario: "sample1", @@ -463,13 +460,13 @@ class someClass2 { }`), } }`); }, - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsChange, + edits: [{ + subScenario: "incremental-declaration-changes", modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"), }], }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "when module option changes", fs: () => projFs, scenario: "sample1", @@ -480,13 +477,13 @@ class someClass2 { }`), "module": "commonjs" } }`), - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsChange, + edits: [{ + subScenario: "incremental-declaration-changes", modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"module": "commonjs"`, `"module": "amd"`), }], }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ subScenario: "when esModuleInterop option changes", fs: () => projFs, scenario: "sample1", @@ -505,8 +502,8 @@ class someClass2 { }`), "esModuleInterop": false } }`), - incrementalScenarios: [{ - buildKind: BuildKind.IncrementalDtsChange, + edits: [{ + subScenario: "incremental-declaration-changes", modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`), }], }); diff --git a/src/testRunner/unittests/tsbuildWatch/programUpdates.ts b/src/testRunner/unittests/tsbuildWatch/programUpdates.ts index 5d63b9b47e157..e6ba2f0e93e52 100644 --- a/src/testRunner/unittests/tsbuildWatch/programUpdates.ts +++ b/src/testRunner/unittests/tsbuildWatch/programUpdates.ts @@ -1,21 +1,6 @@ namespace ts.tscWatch { import projectsLocation = TestFSWithWatch.tsbuildProjectsLocation; describe("unittests:: tsbuildWatch:: watchMode:: program updates", () => { - type TsBuildWatchSystem = TestFSWithWatch.TestServerHostTrackingWrittenFiles; - - function createTsBuildWatchSystem(fileOrFolderList: readonly TestFSWithWatch.FileOrFolderOrSymLink[], params?: TestFSWithWatch.TestServerHostCreationParameters) { - return TestFSWithWatch.changeToHostTrackingWrittenFiles( - createWatchedSystem(fileOrFolderList, params) - ); - } - - type OutputFileStamp = [string, Date | undefined, boolean]; - function transformOutputToOutputFileStamp(f: string, host: TsBuildWatchSystem): OutputFileStamp { - return [f, host.getModifiedTime(f), host.writtenFiles.has(host.toFullPath(f))] as OutputFileStamp; - } - - const scenario = "programUpdates"; - const project = "sample1"; const enum SubProject { core = "core", logic = "logic", @@ -24,17 +9,13 @@ namespace ts.tscWatch { } type ReadonlyFile = Readonly; /** [tsconfig, index] | [tsconfig, index, anotherModule, someDecl] */ - type SubProjectFiles = [ReadonlyFile, ReadonlyFile] | [ReadonlyFile, ReadonlyFile, ReadonlyFile, ReadonlyFile]; - function projectPath(subProject: SubProject) { - return TestFSWithWatch.getTsBuildProjectFilePath(project, subProject); - } - + type SubProjectFiles = [tsconfig: ReadonlyFile, index: ReadonlyFile] | [tsconfig: ReadonlyFile, index: ReadonlyFile, anotherModule: ReadonlyFile, someDecl: ReadonlyFile]; function projectFilePath(subProject: SubProject, baseFileName: string) { - return `${projectPath(subProject)}/${baseFileName.toLowerCase()}`; + return `${TestFSWithWatch.getTsBuildProjectFilePath("sample1", subProject)}/${baseFileName.toLowerCase()}`; } function projectFile(subProject: SubProject, baseFileName: string): File { - return TestFSWithWatch.getTsBuildProjectFile(project, `${subProject}/${baseFileName}`); + return TestFSWithWatch.getTsBuildProjectFile("sample1", `${subProject}/${baseFileName}`); } function subProjectFiles(subProject: SubProject, anotherModuleAndSomeDecl?: true): SubProjectFiles { @@ -48,29 +29,6 @@ namespace ts.tscWatch { return [tsconfig, index, anotherModule, someDecl]; } - function getOutputFileNames(subProject: SubProject, baseFileNameWithoutExtension: string) { - const file = projectFilePath(subProject, baseFileNameWithoutExtension); - return [`${file}.js`, `${file}.d.ts`]; - } - - function getOutputStamps(host: TsBuildWatchSystem, subProject: SubProject, baseFileNameWithoutExtension: string): OutputFileStamp[] { - return getOutputFileNames(subProject, baseFileNameWithoutExtension).map(f => transformOutputToOutputFileStamp(f, host)); - } - - function getOutputFileStamps(host: TsBuildWatchSystem, additionalFiles?: readonly [SubProject, string][]): OutputFileStamp[] { - const result = [ - ...getOutputStamps(host, SubProject.core, "anotherModule"), - ...getOutputStamps(host, SubProject.core, "index"), - ...getOutputStamps(host, SubProject.logic, "index"), - ...getOutputStamps(host, SubProject.tests, "index"), - ]; - if (additionalFiles) { - additionalFiles.forEach(([subProject, baseFileNameWithoutExtension]) => result.push(...getOutputStamps(host, subProject, baseFileNameWithoutExtension))); - } - host.writtenFiles.clear(); - return result; - } - function changeFile(fileName: string | (() => string), content: string | (() => string), caption: string): TscWatchCompileChange { return { caption, @@ -88,8 +46,6 @@ namespace ts.tscWatch { let tests: SubProjectFiles; let ui: SubProjectFiles; let allFiles: readonly File[]; - let testProjectExpectedWatchedFiles: string[]; - let testProjectExpectedWatchedDirectoriesRecursive: string[]; before(() => { core = subProjectFiles(SubProject.core, /*anotherModuleAndSomeDecl*/ true); @@ -97,8 +53,6 @@ namespace ts.tscWatch { tests = subProjectFiles(SubProject.tests); ui = subProjectFiles(SubProject.ui); allFiles = [libFile, ...core, ...logic, ...tests, ...ui]; - testProjectExpectedWatchedFiles = [core[0], core[1], core[2]!, ...logic, ...tests].map(f => f.path.toLowerCase()); - testProjectExpectedWatchedDirectoriesRecursive = [projectPath(SubProject.core), projectPath(SubProject.logic)]; }); after(() => { @@ -107,38 +61,32 @@ namespace ts.tscWatch { tests = undefined!; ui = undefined!; allFiles = undefined!; - testProjectExpectedWatchedFiles = undefined!; - testProjectExpectedWatchedDirectoriesRecursive = undefined!; }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "creates solution in watch mode", - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`], sys: () => createWatchedSystem(allFiles, { currentDirectory: projectsLocation }), changes: emptyArray }); it("verify building references watches only those projects", () => { - const system = createTsBuildWatchSystem(allFiles, { currentDirectory: projectsLocation }); - const host = createSolutionBuilderWithWatchHost(system); - const solutionBuilder = createSolutionBuilderWithWatch(host, [`${project}/${SubProject.tests}`], { watch: true }); - solutionBuilder.buildReferences(`${project}/${SubProject.tests}`); - - checkWatchedFiles(system, testProjectExpectedWatchedFiles.slice(0, testProjectExpectedWatchedFiles.length - tests.length)); - checkWatchedDirectories(system, emptyArray, /*recursive*/ false); - checkWatchedDirectories(system, testProjectExpectedWatchedDirectoriesRecursive, /*recursive*/ true); - - checkOutputErrorsInitial(system, emptyArray); - const testOutput = getOutputStamps(system, SubProject.tests, "index"); - const outputFileStamps = getOutputFileStamps(system); - for (const stamp of outputFileStamps.slice(0, outputFileStamps.length - testOutput.length)) { - assert.isDefined(stamp[1], `${stamp[0]} expected to be present`); - } - for (const stamp of testOutput) { - assert.isUndefined(stamp[1], `${stamp[0]} expected to be missing`); - } - return system; + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem(allFiles, { currentDirectory: projectsLocation })); + const host = createSolutionBuilderWithWatchHostForBaseline(sys, cb); + const solutionBuilder = createSolutionBuilderWithWatch(host, [`sample1/${SubProject.tests}`], { watch: true }); + solutionBuilder.buildReferences(`sample1/${SubProject.tests}`); + runWatchBaseline({ + scenario: "programUpdates", + subScenario: "verify building references watches only those projects", + commandLineArgs: ["--b", "--w"], + sys, + baseline, + oldSnap, + getPrograms, + changes: emptyArray, + watchOrSolution: solutionBuilder + }); }); const buildTests: TscWatchCompileChange = { @@ -163,9 +111,9 @@ namespace ts.tscWatch { }; verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: `${subScenario}/change builds changes and reports found errors message`, - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`], sys: () => createWatchedSystem( allFilesGetter(), { currentDirectory: projectsLocation } @@ -198,9 +146,9 @@ export class someClass2 { }`); }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: `${subScenario}/non local change does not start build of referencing projects`, - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`], sys: () => createWatchedSystem( allFilesGetter(), { currentDirectory: projectsLocation } @@ -217,9 +165,9 @@ function foo() { }`, "Make local change to core"), return changeFile(newFile.path, newFileContent, "Change to new File and build core"); } verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: `${subScenario}/builds when new file is added, and its subsequent updates`, - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`], sys: () => createWatchedSystem( allFilesGetter(), { currentDirectory: projectsLocation } @@ -262,9 +210,9 @@ export class someClass2 { }`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "watches config files that are not present", - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`], sys: () => createWatchedSystem( [libFile, ...core, logic[1], ...tests], { currentDirectory: projectsLocation } @@ -297,9 +245,9 @@ export class someClass2 { }`), timeouts: checkSingleTimeoutQueueLengthAndRunAndVerifyNoTimeout, }; verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "when referenced using prepend builds referencing project even for non local change", - commandLineArgs: ["-b", "-w", `${project}/${SubProject.logic}`], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.logic}`], sys: () => { const coreTsConfig: File = { path: core[0].path, @@ -332,7 +280,7 @@ function myFunc() { return 100; }`, "Make local change and build core"), }); describe("when referenced project change introduces error in the down stream project and then fixes it", () => { - const subProjectLibrary = `${projectsLocation}/${project}/Library`; + const subProjectLibrary = `${projectsLocation}/sample1/Library`; const libraryTs: File = { path: `${subProjectLibrary}/library.ts`, content: ` @@ -349,7 +297,7 @@ export function createSomeObject(): SomeObject }` }; verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "when referenced project change introduces error in the down stream project and then fixes it", commandLineArgs: ["-b", "-w", "App"], sys: () => { @@ -357,7 +305,7 @@ export function createSomeObject(): SomeObject path: `${subProjectLibrary}/tsconfig.json`, content: JSON.stringify({ compilerOptions: { composite: true } }) }; - const subProjectApp = `${projectsLocation}/${project}/App`; + const subProjectApp = `${projectsLocation}/sample1/App`; const appTs: File = { path: `${subProjectApp}/app.ts`, content: `import { createSomeObject } from "../Library/library"; @@ -369,7 +317,7 @@ createSomeObject().message;` }; const files = [libFile, libraryTs, libraryTsconfig, appTs, appTsconfig]; - return createWatchedSystem(files, { currentDirectory: `${projectsLocation}/${project}` }); + return createWatchedSystem(files, { currentDirectory: `${projectsLocation}/sample1` }); }, changes: [ { @@ -398,9 +346,9 @@ createSomeObject().message;` describe("reports errors in all projects on incremental compile", () => { function verifyIncrementalErrors(subScenario: string, buildOptions: readonly string[]) { verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: `reportErrors/${subScenario}`, - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`, ...buildOptions], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`, ...buildOptions], sys: () => createWatchedSystem(allFiles, { currentDirectory: projectsLocation }), changes: [ { @@ -466,7 +414,7 @@ let x: string = 10;`), }; verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "reportErrors/declarationEmitErrors/when fixing error files all files are emitted", commandLineArgs: ["-b", "-w", subProject], sys: () => createWatchedSystem( @@ -479,7 +427,7 @@ let x: string = 10;`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "reportErrors/declarationEmitErrors/when file with no error changes", commandLineArgs: ["-b", "-w", subProject], sys: () => createWatchedSystem( @@ -499,7 +447,7 @@ let x: string = 10;`), }; verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "reportErrors/declarationEmitErrors/introduceError/when fixing errors only changed file is emitted", commandLineArgs: ["-b", "-w", subProject], sys: () => createWatchedSystem( @@ -513,7 +461,7 @@ let x: string = 10;`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "reportErrors/declarationEmitErrors/introduceError/when file with no error changes", commandLineArgs: ["-b", "-w", subProject], sys: () => createWatchedSystem( @@ -530,9 +478,9 @@ let x: string = 10;`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "incremental updates in verbose mode", - commandLineArgs: ["-b", "-w", `${project}/${SubProject.tests}`, "-verbose"], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`, "-verbose"], sys: () => createWatchedSystem(allFiles, { currentDirectory: projectsLocation }), changes: [ { @@ -557,7 +505,7 @@ export function someFn() { }`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "works when noUnusedParameters changes to false", commandLineArgs: ["-b", "-w"], sys: () => { @@ -589,15 +537,15 @@ export function someFn() { }`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "should not trigger recompilation because of program emit", - commandLineArgs: ["-b", "-w", `${project}/${SubProject.core}`, "-verbose"], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.core}`, "-verbose"], sys: () => createWatchedSystem([libFile, ...core], { currentDirectory: projectsLocation }), changes: [ noopChange, { caption: "Add new file", - change: sys => sys.writeFile(`${project}/${SubProject.core}/file3.ts`, `export const y = 10;`), + change: sys => sys.writeFile(`sample1/${SubProject.core}/file3.ts`, `export const y = 10;`), timeouts: checkSingleTimeoutQueueLengthAndRun }, noopChange, @@ -605,9 +553,9 @@ export function someFn() { }`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "should not trigger recompilation because of program emit with outDir specified", - commandLineArgs: ["-b", "-w", `${project}/${SubProject.core}`, "-verbose"], + commandLineArgs: ["-b", "-w", `sample1/${SubProject.core}`, "-verbose"], sys: () => { const [coreConfig, ...rest] = core; const newCoreConfig: File = { path: coreConfig.path, content: JSON.stringify({ compilerOptions: { composite: true, outDir: "outDir" } }) }; @@ -617,7 +565,7 @@ export function someFn() { }`), noopChange, { caption: "Add new file", - change: sys => sys.writeFile(`${project}/${SubProject.core}/file3.ts`, `export const y = 10;`), + change: sys => sys.writeFile(`sample1/${SubProject.core}/file3.ts`, `export const y = 10;`), timeouts: checkSingleTimeoutQueueLengthAndRun }, noopChange @@ -625,7 +573,7 @@ export function someFn() { }`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "works with extended source files", commandLineArgs: ["-b", "-w", "-v", "project1.tsconfig.json", "project2.tsconfig.json"], sys: () => { @@ -711,7 +659,7 @@ export function someFn() { }`), }); verifyTscWatch({ - scenario, + scenario: "programUpdates", subScenario: "works correctly when project with extended config is removed", commandLineArgs: ["-b", "-w", "-v"], sys: () => { diff --git a/src/testRunner/unittests/tsbuildWatch/publicApi.ts b/src/testRunner/unittests/tsbuildWatch/publicApi.ts index bca1472e0d893..21ccf2948c5b6 100644 --- a/src/testRunner/unittests/tsbuildWatch/publicApi.ts +++ b/src/testRunner/unittests/tsbuildWatch/publicApi.ts @@ -40,17 +40,8 @@ export enum e2 { } export function f22() { } // trailing` }; const commandLineArgs = ["--b", "--w"]; - const { sys, baseline, oldSnap } = createBaseline(createWatchedSystem([libFile, solution, sharedConfig, sharedIndex, webpackConfig, webpackIndex], { currentDirectory: projectRoot })); - const { cb, getPrograms } = commandLineCallbacks(sys); - const buildHost = createSolutionBuilderWithWatchHost( - sys, - /*createProgram*/ undefined, - createDiagnosticReporter(sys, /*pretty*/ true), - createBuilderStatusReporter(sys, /*pretty*/ true), - createWatchStatusReporter(sys, /*pretty*/ true) - ); - buildHost.afterProgramEmitAndDiagnostics = cb; - buildHost.afterEmitBundle = cb; + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([libFile, solution, sharedConfig, sharedIndex, webpackConfig, webpackIndex], { currentDirectory: projectRoot })); + const buildHost = createSolutionBuilderWithWatchHostForBaseline(sys, cb); buildHost.getCustomTransformers = getCustomTransformers; const builder = createSolutionBuilderWithWatch(buildHost, [solution.path], { verbose: true }); builder.build(); diff --git a/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts b/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts index 599b5790f85b9..a01b35f5a98cc 100644 --- a/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts +++ b/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts @@ -23,52 +23,56 @@ namespace ts.tscWatch { const allPkgFiles = pkgs(pkgFiles); const system = createWatchedSystem([libFile, typing, ...flatArray(allPkgFiles)], { currentDirectory: project, environmentVariables }); - writePkgReferences(); - const host = createSolutionBuilderWithWatchHost(system); + writePkgReferences(system); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(system); + const host = createSolutionBuilderWithWatchHostForBaseline(sys, cb); const solutionBuilder = createSolutionBuilderWithWatch(host, ["tsconfig.json"], { watch: true, verbose: true }); solutionBuilder.build(); - checkOutputErrorsInitial(system, emptyArray, /*disableConsoleClears*/ undefined, [ - `Projects in this build: \r\n${ - concatenate( - pkgs(index => ` * pkg${index}/tsconfig.json`), - [" * tsconfig.json"] - ).join("\r\n")}\n\n`, - ...flatArray(pkgs(index => [ - `Project 'pkg${index}/tsconfig.json' is out of date because output file 'pkg${index}/index.js' does not exist\n\n`, - `Building project '${project}/pkg${index}/tsconfig.json'...\n\n` - ])) - ]); - - const watchFilesDetailed = arrayToMap(flatArray(allPkgFiles), f => f.path, () => 1); - watchFilesDetailed.set(configPath, 1); - watchFilesDetailed.set(typing.path, singleWatchPerFile ? 1 : maxPkgs); - checkWatchedFilesDetailed(system, watchFilesDetailed); - system.writeFile(typing.path, `${typing.content}export const typing1 = 10;`); - verifyInvoke(); - - // Make change - maxPkgs--; - writePkgReferences(); - system.checkTimeoutQueueLengthAndRun(1); - checkOutputErrorsIncremental(system, emptyArray); - const lastFiles = last(allPkgFiles); - lastFiles.forEach(f => watchFilesDetailed.delete(f.path)); - watchFilesDetailed.set(typing.path, singleWatchPerFile ? 1 : maxPkgs); - checkWatchedFilesDetailed(system, watchFilesDetailed); - system.writeFile(typing.path, typing.content); - verifyInvoke(); - - // Make change to remove all the watches - maxPkgs = 0; - writePkgReferences(); - system.checkTimeoutQueueLengthAndRun(1); - checkOutputErrorsIncremental(system, [ - `tsconfig.json(1,10): error TS18002: The 'files' list in config file '${configPath}' is empty.\n` - ]); - checkWatchedFilesDetailed(system, [configPath], 1); - - system.writeFile(typing.path, `${typing.content}export const typing1 = 10;`); - system.checkTimeoutQueueLength(0); + runWatchBaseline({ + scenario: "watchEnvironment", + subScenario: `same file in multiple projects${singleWatchPerFile ? " with single watcher per file" : ""}`, + commandLineArgs: ["--b", "--w"], + sys, + baseline, + oldSnap, + getPrograms, + changes: [ + { + caption: "modify typing file", + change: sys => sys.writeFile(typing.path, `${typing.content}export const typing1 = 10;`), + timeouts: sys => pkgs(() => sys.checkTimeoutQueueLengthAndRun(1)) + }, + { + // Make change + caption: "change pkg references", + change: sys => { + maxPkgs--; + writePkgReferences(sys); + }, + timeouts: checkSingleTimeoutQueueLengthAndRun, + }, + { + caption: "modify typing file", + change: sys => sys.writeFile(typing.path, typing.content), + timeouts: sys => pkgs(() => sys.checkTimeoutQueueLengthAndRun(1)) + }, + { + // Make change to remove all watches + caption: "change pkg references to remove all watches", + change: sys => { + maxPkgs = 0; + writePkgReferences(sys); + }, + timeouts: checkSingleTimeoutQueueLengthAndRun, + }, + { + caption: "modify typing file", + change: sys => sys.writeFile(typing.path, `${typing.content}export const typing1 = 10;`), + timeouts: sys => pkgs(() => sys.checkTimeoutQueueLengthAndRun(1)) + }, + ], + watchOrSolution: solutionBuilder + }); function flatArray(arr: T[][]): readonly T[] { return flatMap(arr, identity); @@ -101,23 +105,13 @@ namespace ts.tscWatch { } ]; } - function writePkgReferences() { + function writePkgReferences(system: TestFSWithWatch.TestServerHost) { system.writeFile(configPath, JSON.stringify({ files: [], include: [], references: pkgs(createPkgReference) })); } - function verifyInvoke() { - pkgs(() => system.checkTimeoutQueueLengthAndRun(1)); - checkOutputErrorsIncremental(system, emptyArray, /*disableConsoleClears*/ undefined, /*logsBeforeWatchDiagnostics*/ undefined, [ - ...flatArray(pkgs(index => [ - `Project 'pkg${index}/tsconfig.json' is out of date because oldest output 'pkg${index}/index.js' is older than newest input 'typings/xterm.d.ts'\n\n`, - `Building project '${project}/pkg${index}/tsconfig.json'...\n\n`, - `Updating unchanged output timestamps of project '${project}/pkg${index}/tsconfig.json'...\n\n` - ])) - ]); - } }); } }); diff --git a/src/testRunner/unittests/tsc/helpers.ts b/src/testRunner/unittests/tsc/helpers.ts index 14c4bc0df5127..81d22823e0b01 100644 --- a/src/testRunner/unittests/tsc/helpers.ts +++ b/src/testRunner/unittests/tsc/helpers.ts @@ -3,65 +3,56 @@ namespace ts { writtenFiles: Set; baseLine(): { file: string; text: string; }; disableUseFileVersionAsSignature?: boolean; + storeFilesChangingSignatureDuringEmit?: boolean; }; - export enum BuildKind { - Initial = "initial-build", - IncrementalDtsChange = "incremental-declaration-changes", - IncrementalDtsUnchanged = "incremental-declaration-doesnt-change", - IncrementalHeadersChange = "incremental-headers-change-without-dts-changes", - NoChangeRun = "no-change-run" - } - - export const noChangeRun: TscIncremental = { - buildKind: BuildKind.NoChangeRun, + export const noChangeRun: TestTscEdit = { + subScenario: "no-change-run", modifyFs: noop }; + export const noChangeWithExportsDiscrepancyRun: TestTscEdit = { + ...noChangeRun, + discrepancyExplanation: () => [ + "Incremental build did not emit and has .ts as signature so exports has all imported modules/referenced files", + "Clean build always uses d.ts for signature for testing thus does not contain non exported modules/referenced files that arent needed" + ] + }; export const noChangeOnlyRuns = [noChangeRun]; + export const noChangeWithExportsDiscrepancyOnlyRuns = [noChangeWithExportsDiscrepancyRun]; - export interface TscCompile { - scenario: string; - subScenario: string; - buildKind?: BuildKind; // Should be defined for tsc --b - fs: () => vfs.FileSystem; - commandLineArgs: readonly string[]; - - modifyFs?: (fs: vfs.FileSystem) => void; + export interface TestTscCompile extends TestTscCompileLikeBase { baselineSourceMap?: boolean; baselineReadFileCalls?: boolean; baselinePrograms?: boolean; baselineDependencies?: boolean; - disableUseFileVersionAsSignature?: boolean; - environmentVariables?: Record; } - export type CommandLineProgram = [Program, EmitAndSemanticDiagnosticsBuilderProgram?]; + export type CommandLineProgram = [Program, BuilderProgram?]; export interface CommandLineCallbacks { cb: ExecuteCommandLineCallbacks; getPrograms: () => readonly CommandLineProgram[]; } - function isAnyProgram(program: Program | EmitAndSemanticDiagnosticsBuilderProgram | ParsedCommandLine): program is Program | EmitAndSemanticDiagnosticsBuilderProgram { - return !!(program as Program | EmitAndSemanticDiagnosticsBuilderProgram).getCompilerOptions; + function isAnyProgram(program: Program | BuilderProgram | ParsedCommandLine): program is Program | BuilderProgram { + return !!(program as Program | BuilderProgram).getCompilerOptions; } export function commandLineCallbacks( - sys: System & { writtenFiles: ReadonlyCollection; }, + sys: TscCompileSystem | tscWatch.WatchedSystem, originalReadCall?: System["readFile"], - originalWriteFile?: System["writeFile"], ): CommandLineCallbacks { let programs: CommandLineProgram[] | undefined; return { cb: program => { if (isAnyProgram(program)) { - baselineBuildInfo(program.getCompilerOptions(), sys, originalReadCall, originalWriteFile); + baselineBuildInfo(program.getCompilerOptions(), sys, originalReadCall); (programs || (programs = [])).push(isBuilderProgram(program) ? [program.getProgram(), program] : [program] ); } else { - baselineBuildInfo(program.options, sys, originalReadCall, originalWriteFile); + baselineBuildInfo(program.options, sys, originalReadCall); } }, getPrograms: () => { @@ -71,15 +62,28 @@ namespace ts { } }; } + export interface TestTscCompileLikeBase extends VerifyTscCompileLike { + diffWithInitial?: boolean; + modifyFs?: (fs: vfs.FileSystem) => void; + disableUseFileVersionAsSignature?: boolean; + environmentVariables?: Record; + } - export function tscCompile(input: TscCompile) { + export interface TestTscCompileLike extends TestTscCompileLikeBase { + compile: (sys: TscCompileSystem) => void; + additionalBaseline?: (sys: TscCompileSystem) => void; + } + /** + * Initialize FS, run compile function and save baseline + */ + export function testTscCompileLike(input: TestTscCompileLike) { const initialFs = input.fs(); const inputFs = initialFs.shadow(); const { - scenario, subScenario, buildKind, + scenario, subScenario, diffWithInitial, commandLineArgs, modifyFs, - baselineSourceMap, baselineReadFileCalls, baselinePrograms, baselineDependencies, - environmentVariables + environmentVariables, + compile: worker, additionalBaseline, } = input; if (modifyFs) modifyFs(inputFs); inputFs.makeReadonly(); @@ -88,53 +92,20 @@ namespace ts { // Create system const sys = new fakes.System(fs, { executingFilePath: "/lib/tsc", env: environmentVariables }) as TscCompileSystem; if (input.disableUseFileVersionAsSignature) sys.disableUseFileVersionAsSignature = true; - fakes.patchHostForBuildInfoReadWrite(sys); - const writtenFiles = sys.writtenFiles = new Set(); - const originalWriteFile = sys.writeFile; - sys.writeFile = (fileName, content, writeByteOrderMark) => { - const path = toPathWithSystem(sys, fileName); - assert.isFalse(writtenFiles.has(path)); - writtenFiles.add(path); - return originalWriteFile.call(sys, fileName, content, writeByteOrderMark); - }; - const actualReadFileMap: MapLike = {}; - const originalReadFile = sys.readFile; - sys.readFile = path => { - // Dont record libs - if (path.startsWith("/src/")) { - actualReadFileMap[path] = (getProperty(actualReadFileMap, path) || 0) + 1; - } - return originalReadFile.call(sys, path); - }; - + sys.storeFilesChangingSignatureDuringEmit = true; sys.write(`${sys.getExecutingFilePath()} ${commandLineArgs.join(" ")}\n`); sys.exit = exitCode => sys.exitCode = exitCode; - const { cb, getPrograms } = commandLineCallbacks(sys, originalReadFile, originalWriteFile); - executeCommandLine( - sys, - cb, - commandLineArgs, - ); + worker(sys); sys.write(`exitCode:: ExitStatus.${ExitStatus[sys.exitCode as ExitStatus]}\n`); - if (baselinePrograms) { - const baseline: string[] = []; - tscWatch.baselinePrograms(baseline, getPrograms, emptyArray, baselineDependencies); - sys.write(baseline.join("\n")); - } - if (baselineReadFileCalls) { - sys.write(`readFiles:: ${JSON.stringify(actualReadFileMap, /*replacer*/ undefined, " ")} `); - } - if (baselineSourceMap) generateSourceMapBaselineFiles(sys); - + additionalBaseline?.(sys); fs.makeReadonly(); - sys.baseLine = () => { - const baseFsPatch = !buildKind || buildKind === BuildKind.Initial ? - inputFs.diff(/*base*/ undefined, { baseIsNotShadowRoot: true }) : - inputFs.diff(initialFs, { includeChangedFileWithSameContent: true }); + const baseFsPatch = diffWithInitial ? + inputFs.diff(initialFs, { includeChangedFileWithSameContent: true }) : + inputFs.diff(/*base*/ undefined, { baseIsNotShadowRoot: true }); const patch = fs.diff(inputFs, { includeChangedFileWithSameContent: true }); return { - file: `${isBuild(commandLineArgs) ? "tsbuild" : "tsc"}/${scenario}/${buildKind || BuildKind.Initial}/${subScenario.split(" ").join("-")}.js`, + file: `${isBuild(commandLineArgs) ? "tsbuild" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}.js`, text: `Input:: ${baseFsPatch ? vfs.formatPatch(baseFsPatch) : ""} @@ -147,30 +118,126 @@ ${patch ? vfs.formatPatch(patch) : ""}` return sys; } + function makeSystemReadyForBaseline(sys: TscCompileSystem, versionToWrite?: string) { + if (versionToWrite) { + fakes.patchHostForBuildInfoWrite(sys, versionToWrite); + } + else { + fakes.patchHostForBuildInfoReadWrite(sys); + } + const writtenFiles = sys.writtenFiles = new Set(); + const originalWriteFile = sys.writeFile; + sys.writeFile = (fileName, content, writeByteOrderMark) => { + const path = toPathWithSystem(sys, fileName); + // When buildinfo is same for two projects, + // it gives error and doesnt write buildinfo but because buildInfo is written for one project, + // readable baseline will be written two times for those two projects with same contents and is ok + Debug.assert(!writtenFiles.has(path) || endsWith(path, "baseline.txt")); + writtenFiles.add(path); + return originalWriteFile.call(sys, fileName, content, writeByteOrderMark); + }; + } + + export function createSolutionBuilderHostForBaseline( + sys: TscCompileSystem | tscWatch.WatchedSystem, + versionToWrite?: string, + originalRead?: (TscCompileSystem | tscWatch.WatchedSystem)["readFile"] + ) { + if (sys instanceof fakes.System) makeSystemReadyForBaseline(sys, versionToWrite); + const { cb } = commandLineCallbacks(sys, originalRead); + const host = createSolutionBuilderHost(sys, + /*createProgram*/ undefined, + createDiagnosticReporter(sys, /*pretty*/ true), + createBuilderStatusReporter(sys, /*pretty*/ true), + ); + host.afterProgramEmitAndDiagnostics = cb; + host.afterEmitBundle = cb; + return host; + } + + /** + * Initialize Fs, execute command line and save baseline + */ + export function testTscCompile(input: TestTscCompile) { + let actualReadFileMap: MapLike | undefined; + let getPrograms: CommandLineCallbacks["getPrograms"] | undefined; + return testTscCompileLike({ + ...input, + compile: commandLineCompile, + additionalBaseline + }); + + function commandLineCompile(sys: TscCompileSystem) { + makeSystemReadyForBaseline(sys); + actualReadFileMap = {}; + const originalReadFile = sys.readFile; + sys.readFile = path => { + // Dont record libs + if (path.startsWith("/src/")) { + actualReadFileMap![path] = (getProperty(actualReadFileMap!, path) || 0) + 1; + } + return originalReadFile.call(sys, path); + }; + + const result = commandLineCallbacks(sys, originalReadFile); + executeCommandLine( + sys, + result.cb, + input.commandLineArgs, + ); + sys.readFile = originalReadFile; + getPrograms = result.getPrograms; + } + + function additionalBaseline(sys: TscCompileSystem) { + const { baselineSourceMap, baselineReadFileCalls, baselinePrograms, baselineDependencies } = input; + if (baselinePrograms) { + const baseline: string[] = []; + tscWatch.baselinePrograms(baseline, getPrograms!, emptyArray, baselineDependencies); + sys.write(baseline.join("\n")); + } + if (baselineReadFileCalls) { + sys.write(`readFiles:: ${JSON.stringify(actualReadFileMap, /*replacer*/ undefined, " ")} `); + } + if (baselineSourceMap) generateSourceMapBaselineFiles(sys); + actualReadFileMap = undefined; + getPrograms = undefined; + } + } + export function verifyTscBaseline(sys: () => { baseLine: TscCompileSystem["baseLine"]; }) { it(`Generates files matching the baseline`, () => { const { file, text } = sys().baseLine(); Harness.Baseline.runBaseline(file, text); }); } + export interface VerifyTscCompileLike { + scenario: string; + subScenario: string; + commandLineArgs: readonly string[]; + fs: () => vfs.FileSystem; + } - export function verifyTsc(input: TscCompile) { + /** + * Verify by baselining after initializing FS and custom compile + */ + export function verifyTscCompileLike(verifier: (input: T) => { baseLine: TscCompileSystem["baseLine"]; }, input: T) { describe(`tsc ${input.commandLineArgs.join(" ")} ${input.scenario}:: ${input.subScenario}`, () => { describe(input.scenario, () => { describe(input.subScenario, () => { - let sys: TscCompileSystem; - before(() => { - sys = tscCompile({ - ...input, - fs: () => getFsWithTime(input.fs()).fs.makeReadonly() - }); - }); - after(() => { - sys = undefined!; - }); - verifyTscBaseline(() => sys); + verifyTscBaseline(() => verifier({ + ...input, + fs: () => input.fs().makeReadonly() + })); }); }); }); } + + /** + * Verify by baselining after initializing FS and command line compile + */ + export function verifyTsc(input: TestTscCompile) { + verifyTscCompileLike(testTscCompile, input); + } } diff --git a/src/testRunner/unittests/tsc/incremental.ts b/src/testRunner/unittests/tsc/incremental.ts index 2085038fd8048..b3bd30d91aef9 100644 --- a/src/testRunner/unittests/tsc/incremental.ts +++ b/src/testRunner/unittests/tsc/incremental.ts @@ -1,6 +1,6 @@ namespace ts { describe("unittests:: tsc:: incremental::", () => { - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "when passing filename for buildinfo on commandline", fs: () => loadProjectFromFiles({ @@ -17,10 +17,10 @@ namespace ts { }`, }), commandLineArgs: ["--incremental", "--p", "src/project", "--tsBuildInfoFile", "src/project/.tsbuildinfo", "--explainFiles"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "when passing rootDir from commandline", fs: () => loadProjectFromFiles({ @@ -34,10 +34,10 @@ namespace ts { }`, }), commandLineArgs: ["--p", "src/project", "--rootDir", "src/project/src"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "with only dts files", fs: () => loadProjectFromFiles({ @@ -46,16 +46,16 @@ namespace ts { "/src/project/tsconfig.json": "{}", }), commandLineArgs: ["--incremental", "--p", "src/project"], - incrementalScenarios: [ + edits: [ noChangeRun, { - buildKind: BuildKind.IncrementalDtsUnchanged, + subScenario: "incremental-declaration-doesnt-change", modifyFs: fs => appendText(fs, "/src/project/src/main.d.ts", "export const xy = 100;") } ] }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "when passing rootDir is in the tsconfig", fs: () => loadProjectFromFiles({ @@ -70,7 +70,7 @@ namespace ts { }`, }), commandLineArgs: ["--p", "src/project"], - incrementalScenarios: noChangeOnlyRuns + edits: noChangeOnlyRuns }); describe("with noEmitOnError", () => { @@ -82,17 +82,17 @@ namespace ts { projFs = undefined!; }); - function verifyNoEmitOnError(subScenario: string, fixModifyFs: TscIncremental["modifyFs"], modifyFs?: TscIncremental["modifyFs"]) { - verifyTscSerializedIncrementalEdits({ + function verifyNoEmitOnError(subScenario: string, fixModifyFs: TestTscEdit["modifyFs"], modifyFs?: TestTscEdit["modifyFs"]) { + verifyTscWithEdits({ scenario: "incremental", subScenario, fs: () => projFs, commandLineArgs: ["--incremental", "-p", "src"], modifyFs, - incrementalScenarios: [ - noChangeRun, + edits: [ + noChangeWithExportsDiscrepancyRun, { - buildKind: BuildKind.IncrementalDtsUnchanged, + subScenario: "incremental-declaration-doesnt-change", modifyFs: fixModifyFs }, noChangeRun, @@ -123,15 +123,20 @@ const a: string = 10;`, "utf-8"), verifyNoEmitChanges({ composite: true }); function verifyNoEmitChanges(compilerOptions: CompilerOptions) { - const noChangeRunWithNoEmit: TscIncremental = { + const discrepancyIfNoDtsEmit = getEmitDeclarations(compilerOptions) ? + undefined : + noChangeWithExportsDiscrepancyRun.discrepancyExplanation; + const noChangeRunWithNoEmit: TestTscEdit = { + ...noChangeRun, subScenario: "No Change run with noEmit", commandLineArgs: ["--p", "src/project", "--noEmit"], - ...noChangeRun, + discrepancyExplanation: discrepancyIfNoDtsEmit, }; - const noChangeRunWithEmit: TscIncremental = { + const noChangeRunWithEmit: TestTscEdit = { + ...noChangeRun, subScenario: "No Change run with emit", commandLineArgs: ["--p", "src/project"], - ...noChangeRun, + discrepancyExplanation: discrepancyIfNoDtsEmit, }; let optionsString = ""; for (const key in compilerOptions) { @@ -140,24 +145,24 @@ const a: string = 10;`, "utf-8"), } } - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: `noEmit changes${optionsString}`, commandLineArgs: ["--p", "src/project"], fs, - incrementalScenarios: [ + edits: [ noChangeRunWithNoEmit, noChangeRunWithNoEmit, { subScenario: "Introduce error but still noEmit", commandLineArgs: ["--p", "src/project", "--noEmit"], modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"), - buildKind: BuildKind.IncrementalDtsChange + discrepancyExplanation: getEmitDeclarations(compilerOptions) ? noChangeWithExportsDiscrepancyRun.discrepancyExplanation : undefined, }, { subScenario: "Fix error and emit", modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"), - buildKind: BuildKind.IncrementalDtsChange + discrepancyExplanation: discrepancyIfNoDtsEmit }, noChangeRunWithEmit, noChangeRunWithNoEmit, @@ -166,7 +171,7 @@ const a: string = 10;`, "utf-8"), { subScenario: "Introduce error and emit", modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"), - buildKind: BuildKind.IncrementalDtsChange + discrepancyExplanation: discrepancyIfNoDtsEmit }, noChangeRunWithEmit, noChangeRunWithNoEmit, @@ -176,7 +181,7 @@ const a: string = 10;`, "utf-8"), subScenario: "Fix error and no emit", commandLineArgs: ["--p", "src/project", "--noEmit"], modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"), - buildKind: BuildKind.IncrementalDtsChange + discrepancyExplanation: noChangeWithExportsDiscrepancyRun.discrepancyExplanation, }, noChangeRunWithEmit, noChangeRunWithNoEmit, @@ -185,23 +190,22 @@ const a: string = 10;`, "utf-8"), ], }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: `noEmit changes with initial noEmit${optionsString}`, commandLineArgs: ["--p", "src/project", "--noEmit"], fs, - incrementalScenarios: [ + edits: [ noChangeRunWithEmit, { subScenario: "Introduce error with emit", commandLineArgs: ["--p", "src/project"], modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"), - buildKind: BuildKind.IncrementalDtsChange }, { subScenario: "Fix error and no emit", modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"), - buildKind: BuildKind.IncrementalDtsChange + discrepancyExplanation: noChangeWithExportsDiscrepancyRun.discrepancyExplanation }, noChangeRunWithEmit, ], @@ -236,7 +240,7 @@ const a: string = 10;`, "utf-8"), } }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: `when global file is added, the signatures are updated`, fs: () => loadProjectFromFiles({ @@ -257,21 +261,18 @@ const a: string = 10;`, "utf-8"), }), }), commandLineArgs: ["--p", "src/project"], - incrementalScenarios: [ + edits: [ noChangeRun, { subScenario: "Modify main file", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`), }, { subScenario: "Modify main file again", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`), }, { subScenario: "Add new file and update main file", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => { fs.writeFileSync(`/src/project/src/newFile.ts`, "function foo() { return 20; }"); prependText(fs, `/src/project/src/main.ts`, `/// @@ -281,12 +282,10 @@ const a: string = 10;`, "utf-8"), }, { subScenario: "Write file that could not be resolved", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => fs.writeFileSync(`/src/project/src/fileNotFound.ts`, "function something2() { return 20; }"), }, { subScenario: "Modify main file", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`), }, ], @@ -334,7 +333,7 @@ declare global { }); }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "when new file is added to the referenced project", commandLineArgs: ["-i", "-p", `src/projects/project2`], @@ -359,25 +358,21 @@ declare global { }), "/src/projects/project2/class2.ts": `class class2 {}`, }), - incrementalScenarios: [ + edits: [ { subScenario: "Add class3 to project1 and build it", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.ts", `class class3 {}`, "utf-8"), - cleanBuildDiscrepancies: () => new Map([ - // Ts buildinfo will not be updated in incremental build so it will have semantic diagnostics cached from previous build - // But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo - ["/src/projects/project2/tsconfig.tsbuildinfo", CleanBuildDescrepancy.CleanFileTextDifferent] - ]), + discrepancyExplanation: () => [ + "Ts buildinfo will not be updated in incremental build so it will have semantic diagnostics cached from previous build", + "But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo", + ], }, { subScenario: "Add output of class3", - buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"), }, { subScenario: "Add excluded file to project1", - buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => { fs.mkdirSync("/src/projects/project1/temp"); fs.writeFileSync("/src/projects/project1/temp/file.d.ts", `declare class file {}`, "utf-8"); @@ -385,24 +380,21 @@ declare global { }, { subScenario: "Delete output for class3", - buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => fs.unlinkSync("/src/projects/project1/class3.d.ts"), - cleanBuildDiscrepancies: () => new Map([ - // Ts buildinfo willbe updated but will retain lib file errors from previous build and not others because they are emitted because of change which results in clearing their semantic diagnostics cache - // But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo - ["/src/projects/project2/tsconfig.tsbuildinfo", CleanBuildDescrepancy.CleanFileTextDifferent] - ]), + discrepancyExplanation: () => [ + "Ts buildinfo will be updated but will retain lib file errors from previous build and not others because they are emitted because of change which results in clearing their semantic diagnostics cache", + "But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo", + ], }, { subScenario: "Create output for class3", - buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"), }, ] }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "when project has strict true", commandLineArgs: ["-noEmit", "-p", `src/project`], @@ -415,11 +407,11 @@ declare global { }), "/src/project/class1.ts": `export class class1 {}`, }), - incrementalScenarios: noChangeOnlyRuns, + edits: noChangeOnlyRuns, baselinePrograms: true }); - verifyTscSerializedIncrementalEdits({ + verifyTscWithEdits({ scenario: "incremental", subScenario: "serializing error chains", commandLineArgs: ["-p", `src/project`], @@ -447,7 +439,7 @@ declare global {
)` }, `\ninterface ReadonlyArray { readonly length: number }`), - incrementalScenarios: noChangeOnlyRuns, + edits: noChangeOnlyRuns, }); verifyTsc({ @@ -480,5 +472,40 @@ declare global { fs.writeFileSync("/lib/lib.esnext.d.ts", libContent); } }); + + verifyTscWithEdits({ + scenario: "incremental", + subScenario: "change to type that gets used as global through export in another file", + commandLineArgs: ["-p", `src/project`], + fs: () => loadProjectFromFiles({ + "/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { composite: true }, }), + "/src/project/class1.ts": `const a: MagicNumber = 1; +console.log(a);`, + "/src/project/constants.ts": "export default 1;", + "/src/project/types.d.ts": `type MagicNumber = typeof import('./constants').default`, + }), + edits: [{ + subScenario: "Modify imports used in global file", + modifyFs: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"), + }], + }); + + verifyTscWithEdits({ + scenario: "incremental", + subScenario: "change to type that gets used as global through export in another file through indirect import", + commandLineArgs: ["-p", `src/project`], + fs: () => loadProjectFromFiles({ + "/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { composite: true }, }), + "/src/project/class1.ts": `const a: MagicNumber = 1; +console.log(a);`, + "/src/project/constants.ts": "export default 1;", + "/src/project/reexport.ts": `export { default as ConstantNumber } from "./constants"`, + "/src/project/types.d.ts": `type MagicNumber = typeof import('./reexport').ConstantNumber`, + }), + edits: [{ + subScenario: "Modify imports used in global file", + modifyFs: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"), + }], + }); }); } diff --git a/src/testRunner/unittests/tsc/redirect.ts b/src/testRunner/unittests/tsc/redirect.ts new file mode 100644 index 0000000000000..e131ba821af4f --- /dev/null +++ b/src/testRunner/unittests/tsc/redirect.ts @@ -0,0 +1,34 @@ +namespace ts { + describe("unittests:: tsc:: redirect::", () => { + verifyTsc({ + scenario: "redirect", + subScenario: "when redirecting ts file", + fs: () => loadProjectFromFiles({ + "/src/project/tsconfig.json": JSON.stringify({ + compilerOptions: { + outDir: "out" + }, + include: [ + "copy1/node_modules/target/*", + "copy2/node_modules/target/*", + ] + }), + "/src/project/copy1/node_modules/target/index.ts": "export const a = 1;", + "/src/project/copy1/node_modules/target/import.ts": `import {} from "./";`, + "/src/project/copy1/node_modules/target/package.json": JSON.stringify({ + name: "target", + version: "1.0.0", + main: "index.js", + }), + "/src/project/copy2/node_modules/target/index.ts": "export const a = 1;", + "/src/project/copy2/node_modules/target/import.ts": `import {} from "./";`, + "/src/project/copy2/node_modules/target/package.json": JSON.stringify({ + name: "target", + version: "1.0.0", + main: "index.js", + }), + }), + commandLineArgs: ["-p", "src/project"], + }); + }); +} diff --git a/src/testRunner/unittests/tscWatch/consoleClearing.ts b/src/testRunner/unittests/tscWatch/consoleClearing.ts index c874c32e04b31..bde7b6c901863 100644 --- a/src/testRunner/unittests/tscWatch/consoleClearing.ts +++ b/src/testRunner/unittests/tscWatch/consoleClearing.ts @@ -38,7 +38,11 @@ namespace ts.tscWatch { const files = [file, configFile, libFile]; it("using createWatchOfConfigFile ", () => { const baseline = createBaseline(createWatchedSystem(files)); - const watch = createWatchOfConfigFile(configFile.path, baseline.sys); + const watch = createWatchProgram(createWatchCompilerHostOfConfigFileForBaseline({ + system: baseline.sys, + cb: baseline.cb, + configFileName: configFile.path, + })); // Initially console is cleared if --preserveOutput is not provided since the config file is yet to be parsed runWatchBaseline({ scenario, diff --git a/src/testRunner/unittests/tscWatch/helpers.ts b/src/testRunner/unittests/tscWatch/helpers.ts index 881502781b80f..501264b40ff32 100644 --- a/src/testRunner/unittests/tscWatch/helpers.ts +++ b/src/testRunner/unittests/tscWatch/helpers.ts @@ -27,200 +27,6 @@ namespace ts.tscWatch { checkArray(`Program actual files`, program.getSourceFiles().map(file => file.fileName), expectedFiles); } - export function checkProgramRootFiles(program: Program, expectedFiles: readonly string[]) { - checkArray(`Program rootFileNames`, program.getRootFileNames(), expectedFiles); - } - - export type Watch = WatchOfConfigFile | WatchOfFilesAndCompilerOptions; - - export function createWatchOfConfigFile(configFileName: string, system: WatchedSystem, optionsToExtend?: CompilerOptions, watchOptionsToExtend?: WatchOptions) { - const compilerHost = createWatchCompilerHostOfConfigFile({ configFileName, optionsToExtend, watchOptionsToExtend, system }); - return createWatchProgram(compilerHost); - } - - export function createWatchOfFilesAndCompilerOptions(rootFiles: string[], system: WatchedSystem, options: CompilerOptions = {}, watchOptions?: WatchOptions) { - const compilerHost = createWatchCompilerHostOfFilesAndCompilerOptions({ rootFiles, options, watchOptions, system }); - return createWatchProgram(compilerHost); - } - - const elapsedRegex = /^Elapsed:: \d+(?:\.\d+)?ms/; - const buildVerboseLogRegEx = /^.+ \- /; - export enum HostOutputKind { - Log, - Diagnostic, - WatchDiagnostic - } - - export interface HostOutputLog { - kind: HostOutputKind.Log; - expected: string; - caption?: string; - } - - export interface HostOutputDiagnostic { - kind: HostOutputKind.Diagnostic; - diagnostic: Diagnostic | string; - } - - export interface HostOutputWatchDiagnostic { - kind: HostOutputKind.WatchDiagnostic; - diagnostic: Diagnostic | string; - } - - export type HostOutput = HostOutputLog | HostOutputDiagnostic | HostOutputWatchDiagnostic; - - export function checkOutputErrors( - host: WatchedSystem, - expected: readonly HostOutput[], - disableConsoleClears?: boolean | undefined - ) { - let screenClears = 0; - const outputs = host.getOutput(); - assert.equal(outputs.length, expected.length, JSON.stringify(outputs)); - let index = 0; - forEach(expected, expected => { - switch (expected.kind) { - case HostOutputKind.Log: - return assertLog(expected); - case HostOutputKind.Diagnostic: - return assertDiagnostic(expected); - case HostOutputKind.WatchDiagnostic: - return assertWatchDiagnostic(expected); - default: - return Debug.assertNever(expected); - } - }); - assert.equal(host.screenClears.length, screenClears, "Expected number of screen clears"); - host.clearOutput(); - - function isDiagnostic(diagnostic: Diagnostic | string): diagnostic is Diagnostic { - return !!(diagnostic as Diagnostic).messageText; - } - - function assertDiagnostic({ diagnostic }: HostOutputDiagnostic) { - const expected = isDiagnostic(diagnostic) ? formatDiagnostic(diagnostic, host) : diagnostic; - assert.equal(outputs[index], expected, getOutputAtFailedMessage("Diagnostic", expected)); - index++; - } - - function getCleanLogString(log: string) { - return log.replace(elapsedRegex, "").replace(buildVerboseLogRegEx, ""); - } - - function assertLog({ caption, expected }: HostOutputLog) { - const actual = outputs[index]; - assert.equal(getCleanLogString(actual), getCleanLogString(expected), getOutputAtFailedMessage(caption || "Log", expected)); - index++; - } - - function assertWatchDiagnostic({ diagnostic }: HostOutputWatchDiagnostic) { - if (isString(diagnostic)) { - assert.equal(outputs[index], diagnostic, getOutputAtFailedMessage("Diagnostic", diagnostic)); - } - else { - const expected = getWatchDiagnosticWithoutDate(diagnostic); - if (!disableConsoleClears && contains(screenStartingMessageCodes, diagnostic.code)) { - assert.equal(host.screenClears[screenClears], index, `Expected screen clear at this diagnostic: ${expected}`); - screenClears++; - } - assert.isTrue(endsWith(outputs[index], expected), getOutputAtFailedMessage("Watch diagnostic", expected)); - } - index++; - } - - function getOutputAtFailedMessage(caption: string, expectedOutput: string) { - return `Expected ${caption}: ${JSON.stringify(expectedOutput)} at ${index} in ${JSON.stringify(outputs)}`; - } - - function getWatchDiagnosticWithoutDate(diagnostic: Diagnostic) { - const newLines = contains(screenStartingMessageCodes, diagnostic.code) - ? `${host.newLine}${host.newLine}` - : host.newLine; - return ` - ${flattenDiagnosticMessageText(diagnostic.messageText, host.newLine)}${newLines}`; - } - } - - export function hostOutputLog(expected: string, caption?: string): HostOutputLog { - return { kind: HostOutputKind.Log, expected, caption }; - } - export function hostOutputDiagnostic(diagnostic: Diagnostic | string): HostOutputDiagnostic { - return { kind: HostOutputKind.Diagnostic, diagnostic }; - } - export function hostOutputWatchDiagnostic(diagnostic: Diagnostic | string): HostOutputWatchDiagnostic { - return { kind: HostOutputKind.WatchDiagnostic, diagnostic }; - } - - export function startingCompilationInWatchMode() { - return hostOutputWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Starting_compilation_in_watch_mode)); - } - export function foundErrorsWatching(errors: readonly any[]) { - return hostOutputWatchDiagnostic(errors.length === 1 ? - createCompilerDiagnostic(Diagnostics.Found_1_error_Watching_for_file_changes) : - createCompilerDiagnostic(Diagnostics.Found_0_errors_Watching_for_file_changes, errors.length) - ); - } - export function fileChangeDetected() { - return hostOutputWatchDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); - } - - export function checkOutputErrorsInitial(host: WatchedSystem, errors: readonly Diagnostic[] | readonly string[], disableConsoleClears?: boolean, logsBeforeErrors?: string[]) { - checkOutputErrors( - host, - [ - startingCompilationInWatchMode(), - ...map(logsBeforeErrors || emptyArray, expected => hostOutputLog(expected, "logBeforeError")), - ...map(errors, hostOutputDiagnostic), - foundErrorsWatching(errors) - ], - disableConsoleClears - ); - } - - export function checkOutputErrorsIncremental(host: WatchedSystem, errors: readonly Diagnostic[] | readonly string[], disableConsoleClears?: boolean, logsBeforeWatchDiagnostic?: string[], logsBeforeErrors?: string[]) { - checkOutputErrors( - host, - [ - ...map(logsBeforeWatchDiagnostic || emptyArray, expected => hostOutputLog(expected, "logsBeforeWatchDiagnostic")), - fileChangeDetected(), - ...map(logsBeforeErrors || emptyArray, expected => hostOutputLog(expected, "logBeforeError")), - ...map(errors, hostOutputDiagnostic), - foundErrorsWatching(errors) - ], - disableConsoleClears - ); - } - - export function checkOutputErrorsIncrementalWithExit(host: WatchedSystem, errors: readonly Diagnostic[] | readonly string[], expectedExitCode: ExitStatus, disableConsoleClears?: boolean, logsBeforeWatchDiagnostic?: string[], logsBeforeErrors?: string[]) { - checkOutputErrors( - host, - [ - ...map(logsBeforeWatchDiagnostic || emptyArray, expected => hostOutputLog(expected, "logsBeforeWatchDiagnostic")), - fileChangeDetected(), - ...map(logsBeforeErrors || emptyArray, expected => hostOutputLog(expected, "logBeforeError")), - ...map(errors, hostOutputDiagnostic), - ], - disableConsoleClears - ); - assert.equal(host.exitCode, expectedExitCode); - } - - export function checkNormalBuildErrors( - host: WatchedSystem, - errors: readonly Diagnostic[] | readonly string[], - files: readonly ReportFileInError[], - reportErrorSummary?: boolean - ) { - checkOutputErrors( - host, - [ - ...map(errors, hostOutputDiagnostic), - ...reportErrorSummary ? - [hostOutputWatchDiagnostic(getErrorSummaryText(errors.length, files, host.newLine, host))] : - emptyArray - ] - ); - } - export function getDiagnosticMessageChain(message: DiagnosticMessage, args?: (string | number)[], next?: DiagnosticMessageChain[]): DiagnosticMessageChain { let text = getLocaleSpecificMessage(message); if (args?.length) { @@ -293,24 +99,25 @@ namespace ts.tscWatch { sys.checkTimeoutQueueLength(0); } - export interface TscWatchCompileChange { + export type WatchOrSolution = void | SolutionBuilder | WatchOfConfigFile | WatchOfFilesAndCompilerOptions; + export interface TscWatchCompileChange { caption: string; change: (sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles) => void; timeouts: ( sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles, programs: readonly CommandLineProgram[], - watchOrSolution: ReturnType + watchOrSolution: WatchOrSolution ) => void; } export interface TscWatchCheckOptions { baselineSourceMap?: boolean; baselineDependencies?: boolean; } - export interface TscWatchCompileBase extends TscWatchCheckOptions { + export interface TscWatchCompileBase extends TscWatchCheckOptions { scenario: string; subScenario: string; commandLineArgs: readonly string[]; - changes: readonly TscWatchCompileChange[]; + changes: readonly TscWatchCompileChange[]; } export interface TscWatchCompile extends TscWatchCompileBase { sys: () => WatchedSystem; @@ -355,23 +162,82 @@ namespace ts.tscWatch { }); } - export interface Baseline { + export interface BaselineBase { baseline: string[]; sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles; oldSnap: SystemSnap; } - export function createBaseline(system: WatchedSystem): Baseline { - const sys = TestFSWithWatch.changeToHostTrackingWrittenFiles( - fakes.patchHostForBuildInfoReadWrite(system) - ); + export interface Baseline extends BaselineBase, CommandLineCallbacks { + } + + export function createBaseline(system: WatchedSystem, modifySystem?: (sys: WatchedSystem, originalRead: WatchedSystem["readFile"]) => void): Baseline { + const originalRead = system.readFile; + const initialSys = fakes.patchHostForBuildInfoReadWrite(system); + modifySystem?.(initialSys, originalRead); + const sys = TestFSWithWatch.changeToHostTrackingWrittenFiles(initialSys); const baseline: string[] = []; baseline.push("Input::"); sys.diff(baseline); - return { sys, baseline, oldSnap: sys.snap() }; + const { cb, getPrograms } = commandLineCallbacks(sys); + return { sys, baseline, oldSnap: sys.snap(), cb, getPrograms }; } - export function applyChange(sys: Baseline["sys"], baseline: Baseline["baseline"], change: TscWatchCompileChange["change"], caption?: TscWatchCompileChange["caption"]) { + export function createSolutionBuilderWithWatchHostForBaseline(sys: WatchedSystem, cb: ExecuteCommandLineCallbacks) { + const host = createSolutionBuilderWithWatchHost(sys, + /*createProgram*/ undefined, + createDiagnosticReporter(sys, /*pretty*/ true), + createBuilderStatusReporter(sys, /*pretty*/ true), + createWatchStatusReporter(sys, /*pretty*/ true) + ); + host.afterProgramEmitAndDiagnostics = cb; + host.afterEmitBundle = cb; + return host; + } + + interface CreateWatchCompilerHostOfConfigFileForBaseline extends CreateWatchCompilerHostOfConfigFileInput { + system: WatchedSystem, + cb: ExecuteCommandLineCallbacks; + } + + export function createWatchCompilerHostOfConfigFileForBaseline( + input: CreateWatchCompilerHostOfConfigFileForBaseline + ) { + const host = createWatchCompilerHostOfConfigFile({ + ...input, + reportDiagnostic: createDiagnosticReporter(input.system, /*pretty*/ true), + reportWatchStatus: createWatchStatusReporter(input.system, /*pretty*/ true), + }); + updateWatchHostForBaseline(host, input.cb); + return host; + } + + interface CreateWatchCompilerHostOfFilesAndCompilerOptionsForBaseline extends CreateWatchCompilerHostOfFilesAndCompilerOptionsInput { + system: WatchedSystem, + cb: ExecuteCommandLineCallbacks; + } + export function createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline( + input: CreateWatchCompilerHostOfFilesAndCompilerOptionsForBaseline + ) { + const host = createWatchCompilerHostOfFilesAndCompilerOptions({ + ...input, + reportDiagnostic: createDiagnosticReporter(input.system, /*pretty*/ true), + reportWatchStatus: createWatchStatusReporter(input.system, /*pretty*/ true), + }); + updateWatchHostForBaseline(host, input.cb); + return host; + } + + function updateWatchHostForBaseline(host: WatchCompilerHost, cb: ExecuteCommandLineCallbacks) { + const emitFilesAndReportErrors = host.afterProgramCreate!; + host.afterProgramCreate = builderProgram => { + emitFilesAndReportErrors.call(host, builderProgram); + cb(builderProgram); + }; + return host; + } + + export function applyChange(sys: BaselineBase["sys"], baseline: BaselineBase["baseline"], change: TscWatchCompileChange["change"], caption?: TscWatchCompileChange["caption"]) { const oldSnap = sys.snap(); baseline.push(`Change::${caption ? " " + caption : ""}`, ""); change(sys); @@ -380,17 +246,17 @@ namespace ts.tscWatch { return sys.snap(); } - export interface RunWatchBaseline extends Baseline, TscWatchCompileBase { + export interface RunWatchBaseline extends BaselineBase, TscWatchCompileBase { sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles; getPrograms: () => readonly CommandLineProgram[]; - watchOrSolution: ReturnType; + watchOrSolution: WatchOrSolution; } - export function runWatchBaseline({ + export function runWatchBaseline({ scenario, subScenario, commandLineArgs, getPrograms, sys, baseline, oldSnap, baselineSourceMap, baselineDependencies, changes, watchOrSolution - }: RunWatchBaseline) { + }: RunWatchBaseline) { baseline.push(`${sys.getExecutingFilePath()} ${commandLineArgs.join(" ")}`); let programs = watchBaseline({ baseline, @@ -415,9 +281,7 @@ namespace ts.tscWatch { baselineDependencies, }); } - Harness.Baseline.runBaseline(`${isBuild(commandLineArgs) ? - isWatch(commandLineArgs) ? "tsbuild/watchMode" : "tsbuild" : - isWatch(commandLineArgs) ? "tscWatch" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}.js`, baseline.join("\r\n")); + Harness.Baseline.runBaseline(`${isBuild(commandLineArgs) ? "tsbuild" : "tsc"}${isWatch(commandLineArgs) ? "Watch" : ""}/${scenario}/${subScenario.split(" ").join("-")}.js`, baseline.join("\r\n")); } function isWatch(commandLineArgs: readonly string[]) { @@ -428,7 +292,7 @@ namespace ts.tscWatch { }); } - export interface WatchBaseline extends Baseline, TscWatchCheckOptions { + export interface WatchBaseline extends BaselineBase, TscWatchCheckOptions { oldPrograms: readonly (CommandLineProgram | undefined)[]; getPrograms: () => readonly CommandLineProgram[]; } @@ -473,7 +337,7 @@ namespace ts.tscWatch { if (!builderProgram) return; if (builderProgram !== oldProgram?.[1]) { const state = builderProgram.getState(); - const internalState = state as unknown as BuilderState; + const internalState = state as unknown as BuilderProgramState; if (state.semanticDiagnosticsPerFile?.size) { baseline.push("Semantic diagnostics in builder refreshed for::"); for (const file of program.getSourceFiles()) { @@ -491,9 +355,12 @@ namespace ts.tscWatch { baseline.push("Shape signatures in builder refreshed for::"); internalState.hasCalledUpdateShapeSignature.forEach((path: Path) => { const info = state.fileInfos.get(path); - if(info?.version === info?.signature || !info?.signature) { + if (info?.version === info?.signature || !info?.signature) { baseline.push(path + " (used version)"); } + else if (internalState.filesChangingSignature?.has(path)) { + baseline.push(path + " (computed .d.ts during emit)"); + } else { baseline.push(path + " (computed .d.ts)"); } @@ -544,30 +411,32 @@ namespace ts.tscWatch { sys.writeFile(file, content.replace(searchValue, replaceValue)); } - export function createSolutionBuilder(system: WatchedSystem, rootNames: readonly string[], defaultOptions?: BuildOptions) { - const host = createSolutionBuilderHost(system); - return ts.createSolutionBuilder(host, rootNames, defaultOptions || {}); + export function createSolutionBuilder(system: WatchedSystem, rootNames: readonly string[], originalRead?: WatchedSystem["readFile"]) { + const host = createSolutionBuilderHostForBaseline(system, /*versionToWrite*/ undefined, originalRead); + return ts.createSolutionBuilder(host, rootNames, {}); } export function ensureErrorFreeBuild(host: WatchedSystem, rootNames: readonly string[]) { // ts build should succeed - const solutionBuilder = createSolutionBuilder(host, rootNames, {}); - solutionBuilder.build(); + solutionBuildWithBaseline(host, rootNames); assert.equal(host.getOutput().length, 0, JSON.stringify(host.getOutput(), /*replacer*/ undefined, " ")); } - export function createSystemWithSolutionBuild(solutionRoots: readonly string[], files: readonly TestFSWithWatch.FileOrFolderOrSymLink[], params?: TestFSWithWatch.TestServerHostCreationParameters) { - const sys = createWatchedSystem(files, params); + export function solutionBuildWithBaseline(sys: WatchedSystem, solutionRoots: readonly string[], originalRead?: WatchedSystem["readFile"]) { const originalReadFile = sys.readFile; const originalWrite = sys.write; const originalWriteFile = sys.writeFile; const solutionBuilder = createSolutionBuilder(TestFSWithWatch.changeToHostTrackingWrittenFiles( fakes.patchHostForBuildInfoReadWrite(sys) - ), solutionRoots, {}); + ), solutionRoots, originalRead); solutionBuilder.build(); sys.readFile = originalReadFile; sys.write = originalWrite; sys.writeFile = originalWriteFile; return sys; } + + export function createSystemWithSolutionBuild(solutionRoots: readonly string[], files: readonly TestFSWithWatch.FileOrFolderOrSymLink[], params?: TestFSWithWatch.TestServerHostCreationParameters) { + return solutionBuildWithBaseline(createWatchedSystem(files, params), solutionRoots); + } } diff --git a/src/testRunner/unittests/tscWatch/incremental.ts b/src/testRunner/unittests/tscWatch/incremental.ts index 8da2d0c09c4ba..1af240764fea7 100644 --- a/src/testRunner/unittests/tscWatch/incremental.ts +++ b/src/testRunner/unittests/tscWatch/incremental.ts @@ -28,12 +28,11 @@ namespace ts.tscWatch { { subScenario, files, optionsToExtend, modifyFs }: VerifyIncrementalWatchEmitInput, incremental: boolean ) { - const { sys, baseline, oldSnap } = createBaseline(createWatchedSystem(files(), { currentDirectory: project })); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem(files(), { currentDirectory: project })); if (incremental) sys.exit = exitCode => sys.exitCode = exitCode; const argsToPass = [incremental ? "-i" : "-w", ...(optionsToExtend || emptyArray)]; baseline.push(`${sys.getExecutingFilePath()} ${argsToPass.join(" ")}`); let oldPrograms: readonly CommandLineProgram[] = emptyArray; - const { cb, getPrograms } = commandLineCallbacks(sys); build(oldSnap); if (modifyFs) { diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index ea5ab542f52a9..68f03f0d20cc4 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -511,7 +511,7 @@ export class A { }] }); - it("correctly migrate files between projects", () => { + it("two watch programs are not affected by each other", () => { const file1 = { path: "/a/b/f1.ts", content: ` @@ -526,16 +526,46 @@ export class A { path: "/a/d/f3.ts", content: "export let y = 1;" }; - const host = createWatchedSystem([file1, file2, file3]); - const watch = createWatchOfFilesAndCompilerOptions([file2.path, file3.path], host); - checkProgramActualFiles(watch.getCurrentProgram().getProgram(), [file2.path, file3.path]); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([libFile, file1, file2, file3])); + const host = createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline({ + rootFiles: [file2.path, file3.path], + system: sys, + options: { allowNonTsExtensions: true }, + cb, + watchOptions: undefined + }); + createWatchProgram(host); + baseline.push(`${sys.getExecutingFilePath()} --w ${file2.path} ${file3.path}`); + watchBaseline({ + baseline, + getPrograms, + oldPrograms: emptyArray, + sys, + oldSnap, + }); - const watch2 = createWatchOfFilesAndCompilerOptions([file1.path], host); - checkProgramActualFiles(watch2.getCurrentProgram().getProgram(), [file1.path, file2.path, file3.path]); + const {cb: cb2, getPrograms: getPrograms2 } = commandLineCallbacks(sys); + const oldSnap2 = sys.snap(); + baseline.push("createing separate watcher"); + createWatchProgram(createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline({ + rootFiles:[file1.path], + system: sys, + options: { allowNonTsExtensions: true }, + cb: cb2, + watchOptions: undefined + })); + watchBaseline({ + baseline, + getPrograms: getPrograms2, + oldPrograms: emptyArray, + sys, + oldSnap: oldSnap2, + }); - // Previous program shouldnt be updated - checkProgramActualFiles(watch.getCurrentProgram().getProgram(), [file2.path, file3.path]); - host.checkTimeoutQueueLength(0); + sys.checkTimeoutQueueLength(0); + baseline.push(`First program is not updated:: ${getPrograms() === emptyArray}`); + baseline.push(`Second program is not updated:: ${getPrograms2() === emptyArray}`); + Harness.Baseline.runBaseline(`tscWatch/${scenario}/two-watch-programs-are-not-affected-by-each-other.js`, baseline.join("\r\n")); }); verifyTscWatch({ @@ -1025,9 +1055,25 @@ declare const eval: any` path: "/a/compile", content: "let x = 1" }; - const host = createWatchedSystem([f, libFile]); - const watch = createWatchOfFilesAndCompilerOptions([f.path], host, { allowNonTsExtensions: true }); - checkProgramActualFiles(watch.getCurrentProgram().getProgram(), [f.path, libFile.path]); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([f, libFile])); + const watch = createWatchProgram(createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline({ + rootFiles: [f.path], + system: sys, + options: { allowNonTsExtensions: true }, + cb, + watchOptions: undefined + })); + runWatchBaseline({ + scenario, + subScenario: "should support files without extensions", + commandLineArgs: ["--w", f.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: emptyArray, + watchOrSolution: watch + }); }); verifyTscWatch({ diff --git a/src/testRunner/unittests/tscWatch/resolutionCache.ts b/src/testRunner/unittests/tscWatch/resolutionCache.ts index b8f065ae41b82..ef923e28d3cae 100644 --- a/src/testRunner/unittests/tscWatch/resolutionCache.ts +++ b/src/testRunner/unittests/tscWatch/resolutionCache.ts @@ -1,7 +1,7 @@ namespace ts.tscWatch { describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution caching", () => { const scenario = "resolutionCache"; - it("works", () => { + it("caching works", () => { const root = { path: "/a/d/f0.ts", content: `import {x} from "f1"` @@ -11,80 +11,76 @@ namespace ts.tscWatch { content: `foo()` }; - const files = [root, imported, libFile]; - const host = createWatchedSystem(files); - const watch = createWatchOfFilesAndCompilerOptions([root.path], host, { module: ModuleKind.AMD }); - - const f1IsNotModule = getDiagnosticOfFileFromProgram(watch.getCurrentProgram().getProgram(), root.path, root.content.indexOf('"f1"'), '"f1"'.length, Diagnostics.File_0_is_not_a_module, imported.path); - const cannotFindFoo = getDiagnosticOfFileFromProgram(watch.getCurrentProgram().getProgram(), imported.path, imported.content.indexOf("foo"), "foo".length, Diagnostics.Cannot_find_name_0, "foo"); - - // ensure that imported file was found - checkOutputErrorsInitial(host, [f1IsNotModule, cannotFindFoo]); - + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([root, imported, libFile])); + const host = createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline({ + rootFiles: [root.path], + system: sys, + options: { module: ModuleKind.AMD }, + cb, + watchOptions: undefined + }); const originalFileExists = host.fileExists; - { - const newContent = `import {x} from "f1" - var x: string = 1;`; - root.content = newContent; - host.writeFile(root.path, root.content); - - // patch fileExists to make sure that disk is not touched - host.fileExists = notImplemented; - - // trigger synchronization to make sure that import will be fetched from the cache - host.runQueuedTimeoutCallbacks(); - - // ensure file has correct number of errors after edit - checkOutputErrorsIncremental(host, [ - f1IsNotModule, - getDiagnosticOfFileFromProgram(watch.getCurrentProgram().getProgram(), root.path, newContent.indexOf("var x") + "var ".length, "x".length, Diagnostics.Type_0_is_not_assignable_to_type_1, "number", "string"), - cannotFindFoo - ]); - } - { - let fileExistsIsCalled = false; - host.fileExists = (fileName): boolean => { - if (fileName === "lib.d.ts") { - return false; - } - fileExistsIsCalled = true; - assert.isTrue(fileName.indexOf("/f2.") !== -1); - return originalFileExists.call(host, fileName); - }; - - root.content = `import {x} from "f2"`; - host.writeFile(root.path, root.content); - - // trigger synchronization to make sure that system will try to find 'f2' module on disk - host.runQueuedTimeoutCallbacks(); - - // ensure file has correct number of errors after edit - checkOutputErrorsIncremental(host, [ - getDiagnosticModuleNotFoundOfFile(watch.getCurrentProgram().getProgram(), root, "f2") - ]); - - assert.isTrue(fileExistsIsCalled); - } - { - let fileExistsCalled = false; - host.fileExists = (fileName): boolean => { - if (fileName === "lib.d.ts") { - return false; - } - fileExistsCalled = true; - assert.isTrue(fileName.indexOf("/f1.") !== -1); - return originalFileExists.call(host, fileName); - }; - - const newContent = `import {x} from "f1"`; - root.content = newContent; - - host.writeFile(root.path, root.content); - host.runQueuedTimeoutCallbacks(); - - checkOutputErrorsIncremental(host, [f1IsNotModule, cannotFindFoo]); - assert.isTrue(fileExistsCalled); - } + const watch = createWatchProgram(host); + let fileExistsIsCalled = false; + runWatchBaseline({ + scenario: "resolutionCache", + subScenario: "caching works", + commandLineArgs: ["--w", root.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: [ + { + caption: "Adding text doesnt re-resole the imports", + change: sys => { + // patch fileExists to make sure that disk is not touched + host.fileExists = notImplemented; + sys.writeFile(root.path, `import {x} from "f1" + var x: string = 1;`); + }, + timeouts: runQueuedTimeoutCallbacks + }, + { + caption: "Resolves f2", + change: sys => { + host.fileExists = (fileName): boolean => { + if (fileName === "lib.d.ts") { + return false; + } + fileExistsIsCalled = true; + assert.isTrue(fileName.indexOf("/f2.") !== -1); + return originalFileExists.call(host, fileName); + }; + sys.writeFile(root.path, `import {x} from "f2"`); + }, + timeouts: sys => { + sys.runQueuedTimeoutCallbacks(); + assert.isTrue(fileExistsIsCalled); + }, + }, + { + caption: "Resolve f1", + change: sys => { + fileExistsIsCalled = false; + host.fileExists = (fileName): boolean => { + if (fileName === "lib.d.ts") { + return false; + } + fileExistsIsCalled = true; + assert.isTrue(fileName.indexOf("/f1.") !== -1); + return originalFileExists.call(host, fileName); + }; + sys.writeFile(root.path, `import {x} from "f1"`); + }, + timeouts: sys => { + sys.runQueuedTimeoutCallbacks(); + assert.isTrue(fileExistsIsCalled); + } + }, + ], + watchOrSolution: watch + }); }); it("loads missing files from disk", () => { @@ -98,10 +94,15 @@ namespace ts.tscWatch { content: `export const y = 1;` }; - const files = [root, libFile]; - const host = createWatchedSystem(files); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([root, libFile])); + const host = createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline({ + rootFiles: [root.path], + system: sys, + options: { module: ModuleKind.AMD }, + cb, + watchOptions: undefined + }); const originalFileExists = host.fileExists; - let fileExistsCalledForBar = false; host.fileExists = fileName => { if (fileName === "lib.d.ts") { @@ -114,21 +115,30 @@ namespace ts.tscWatch { return originalFileExists.call(host, fileName); }; - const watch = createWatchOfFilesAndCompilerOptions([root.path], host, { module: ModuleKind.AMD }); - + const watch = createWatchProgram(host); assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called"); - checkOutputErrorsInitial(host, [ - getDiagnosticModuleNotFoundOfFile(watch.getCurrentProgram().getProgram(), root, "bar") - ]); - - fileExistsCalledForBar = false; - root.content = `import {y} from "bar"`; - host.writeFile(root.path, root.content); - host.writeFile(imported.path, imported.content); - - host.runQueuedTimeoutCallbacks(); - checkOutputErrorsIncremental(host, emptyArray); - assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); + runWatchBaseline({ + scenario: "resolutionCache", + subScenario: "loads missing files from disk", + commandLineArgs: ["--w", root.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: [{ + caption: "write imported file", + change: sys => { + fileExistsCalledForBar = false; + sys.writeFile(root.path,`import {y} from "bar"`); + sys.writeFile(imported.path, imported.content); + }, + timeouts: sys => { + sys.runQueuedTimeoutCallbacks(); + assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); + } + }], + watchOrSolution: watch + }); }); it("should compile correctly when resolved module goes missing and then comes back (module is not part of the root)", () => { @@ -142,7 +152,14 @@ namespace ts.tscWatch { content: `export const y = 1;export const x = 10;` }; - const host = createWatchedSystem([root, libFile, imported]); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([root, imported, libFile])); + const host = createWatchCompilerHostOfFilesAndCompilerOptionsForBaseline({ + rootFiles: [root.path], + system: sys, + options: { module: ModuleKind.AMD }, + cb, + watchOptions: undefined + }); const originalFileExists = host.fileExists; let fileExistsCalledForBar = false; host.fileExists = fileName => { @@ -154,26 +171,43 @@ namespace ts.tscWatch { } return originalFileExists.call(host, fileName); }; - - const watch = createWatchOfFilesAndCompilerOptions([root.path], host, { module: ModuleKind.AMD }); - + const watch = createWatchProgram(host); assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called"); - checkOutputErrorsInitial(host, emptyArray); - - fileExistsCalledForBar = false; - host.deleteFile(imported.path); - host.runQueuedTimeoutCallbacks(); - assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); - checkOutputErrorsIncremental(host, [ - getDiagnosticModuleNotFoundOfFile(watch.getCurrentProgram().getProgram(), root, "bar") - ]); - - fileExistsCalledForBar = false; - host.writeFile(imported.path, imported.content); - host.checkTimeoutQueueLengthAndRun(1); // Scheduled invalidation of resolutions - host.checkTimeoutQueueLengthAndRun(1); // Actual update - checkOutputErrorsIncremental(host, emptyArray); - assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); + runWatchBaseline({ + scenario: "resolutionCache", + subScenario: "should compile correctly when resolved module goes missing and then comes back", + commandLineArgs: ["--w", root.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: [ + { + caption: "Delete imported file", + change: sys => { + fileExistsCalledForBar = false; + sys.deleteFile(imported.path); + }, + timeouts: sys => { + sys.runQueuedTimeoutCallbacks(); + assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); + }, + }, + { + caption: "Create imported file", + change: sys => { + fileExistsCalledForBar = false; + sys.writeFile(imported.path, imported.content); + }, + timeouts: sys => { + sys.checkTimeoutQueueLengthAndRun(1); // Scheduled invalidation of resolutions + sys.checkTimeoutQueueLengthAndRun(1); // Actual update + assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); + }, + }, + ], + watchOrSolution: watch + }); }); verifyTscWatch({ @@ -402,7 +436,7 @@ declare namespace myapp { change: noop, timeouts: (sys, [[oldProgram, oldBuilderProgram]], watchorSolution) => { sys.checkTimeoutQueueLength(0); - const newProgram = (watchorSolution as Watch).getProgram(); + const newProgram = (watchorSolution as WatchOfConfigFile).getProgram(); assert.strictEqual(newProgram, oldBuilderProgram, "No change so builder program should be same"); assert.strictEqual(newProgram.getProgram(), oldProgram, "No change so program should be same"); } diff --git a/src/testRunner/unittests/tscWatch/sourceOfProjectReferenceRedirect.ts b/src/testRunner/unittests/tscWatch/sourceOfProjectReferenceRedirect.ts index 4a831626e4e22..4110dbfe3331b 100644 --- a/src/testRunner/unittests/tscWatch/sourceOfProjectReferenceRedirect.ts +++ b/src/testRunner/unittests/tscWatch/sourceOfProjectReferenceRedirect.ts @@ -4,26 +4,35 @@ namespace ts.tscWatch { interface VerifyWatchInput { files: readonly TestFSWithWatch.FileOrFolderOrSymLink[]; config: string; - expectedProgramFiles: readonly string[]; + subScenario: string; } - function verifyWatch( - { files, config, expectedProgramFiles }: VerifyWatchInput, - alreadyBuilt: boolean - ) { - const sys = createWatchedSystem(files); - if (alreadyBuilt) { - const solutionBuilder = createSolutionBuilder(sys, [config], {}); - solutionBuilder.build(); - solutionBuilder.close(); - sys.clearOutput(); - } - const host = createWatchCompilerHostOfConfigFile({ + + function verifyWatch({ files, config, subScenario }: VerifyWatchInput, alreadyBuilt: boolean) { + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline( + createWatchedSystem(files), + alreadyBuilt ? (sys, originalRead) => { + solutionBuildWithBaseline(sys, [config], originalRead); + sys.clearOutput(); + } : undefined + ); + const host = createWatchCompilerHostOfConfigFileForBaseline({ configFileName: config, - system: sys + system: sys, + cb, }); host.useSourceOfProjectReferenceRedirect = returnTrue; const watch = createWatchProgram(host); - checkProgramActualFiles(watch.getCurrentProgram().getProgram(), expectedProgramFiles); + runWatchBaseline({ + scenario: "sourceOfProjectReferenceRedirect", + subScenario: `${subScenario}${alreadyBuilt ? " when solution is already built" : ""}`, + commandLineArgs: ["--w", "--p", config], + sys, + baseline, + oldSnap, + getPrograms, + changes: emptyArray, + watchOrSolution: watch + }); } function verifyScenario(input: () => VerifyWatchInput) { @@ -48,7 +57,7 @@ namespace ts.tscWatch { return { files: [{ path: libFile.path, content: libContent }, baseConfig, coreTs, coreConfig, animalTs, dogTs, indexTs, animalsConfig], config: animalsConfig.path, - expectedProgramFiles: [libFile.path, indexTs.path, dogTs.path, animalTs.path, coreTs.path] + subScenario: "with simple project" }; }); }); @@ -60,6 +69,7 @@ namespace ts.tscWatch { bFoo: File; bBar: File; bSymlink: SymLink; + subScenario: string; } function verifySymlinkScenario(packages: () => Packages) { describe("when preserveSymlinks is turned off", () => { @@ -72,13 +82,13 @@ namespace ts.tscWatch { function verifySymlinkScenarioWorker(packages: () => Packages, extraOptions: CompilerOptions) { verifyScenario(() => { - const { bPackageJson, aTest, bFoo, bBar, bSymlink } = packages(); + const { bPackageJson, aTest, bFoo, bBar, bSymlink, subScenario } = packages(); const aConfig = config("A", extraOptions, ["../B"]); const bConfig = config("B", extraOptions); return { files: [libFile, bPackageJson, aConfig, bConfig, aTest, bFoo, bBar, bSymlink], config: aConfig.path, - expectedProgramFiles: [libFile.path, aTest.path, bFoo.path, bBar.path] + subScenario: `${subScenario}${extraOptions.preserveSymlinks ? " with preserveSymlinks" : ""}` }; }); } @@ -126,7 +136,8 @@ bar(); bSymlink: { path: `${projectRoot}/node_modules/${scope}b`, symLink: `${projectRoot}/packages/B` - } + }, + subScenario: `when packageJson has types field${scope ? " with scoped package" : ""}` })); }); @@ -146,7 +157,8 @@ bar(); bSymlink: { path: `${projectRoot}/node_modules/${scope}b`, symLink: `${projectRoot}/packages/B` - } + }, + subScenario: `when referencing file from subFolder${scope ? " with scoped package" : ""}` })); }); } diff --git a/src/testRunner/unittests/tscWatch/watchApi.ts b/src/testRunner/unittests/tscWatch/watchApi.ts index d71318d2de868..477a982eafde2 100644 --- a/src/testRunner/unittests/tscWatch/watchApi.ts +++ b/src/testRunner/unittests/tscWatch/watchApi.ts @@ -18,15 +18,18 @@ namespace ts.tscWatch { }; it("verify that module resolution with json extension works when returned without extension", () => { - const files = [libFile, mainFile, config, settingsJson]; - const host = createWatchedSystem(files, { currentDirectory: projectRoot }); - const compilerHost = createWatchCompilerHostOfConfigFile({ + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem( + [libFile, mainFile, config, settingsJson], + { currentDirectory: projectRoot }), + ); + const host = createWatchCompilerHostOfConfigFileForBaseline({ configFileName: config.path, - system: host + system: sys, + cb, }); - const parsedCommandResult = parseJsonConfigFileContent(configFileJson, host, config.path); - compilerHost.resolveModuleNames = (moduleNames, containingFile) => moduleNames.map(m => { - const result = resolveModuleName(m, containingFile, parsedCommandResult.options, compilerHost); + const parsedCommandResult = parseJsonConfigFileContent(configFileJson, sys, config.path); + host.resolveModuleNames = (moduleNames, containingFile) => moduleNames.map(m => { + const result = resolveModuleName(m, containingFile, parsedCommandResult.options, host); const resolvedModule = result.resolvedModule!; return { resolvedFileName: resolvedModule.resolvedFileName, @@ -34,40 +37,62 @@ namespace ts.tscWatch { originalFileName: resolvedModule.originalPath, }; }); - const watch = createWatchProgram(compilerHost); - const program = watch.getCurrentProgram().getProgram(); - checkProgramActualFiles(program, [mainFile.path, libFile.path, settingsJson.path]); + const watch = createWatchProgram(host); + runWatchBaseline({ + scenario: "watchApi", + subScenario: "verify that module resolution with json extension works when returned without extension", + commandLineArgs: ["--w", "--p", config.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: emptyArray, + watchOrSolution: watch + }); }); }); describe("unittests:: tsc-watch:: watchAPI:: tsc-watch expose error count to watch status reporter", () => { - const configFileJson: any = { - compilerOptions: { module: "commonjs" }, - files: ["index.ts"] - }; - const config: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify(configFileJson) - }; - const mainFile: File = { - path: `${projectRoot}/index.ts`, - content: "let compiler = new Compiler(); for (let i = 0; j < 5; i++) {}" - }; - it("verify that the error count is correctly passed down to the watch status reporter", () => { - const files = [libFile, mainFile, config]; - const host = createWatchedSystem(files, { currentDirectory: projectRoot }); - let watchedErrorCount; - const reportWatchStatus: WatchStatusReporter = (_, __, ___, errorCount) => { - watchedErrorCount = errorCount; + const config: File = { + path: `${projectRoot}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { module: "commonjs" }, + files: ["index.ts"] + }) }; - const compilerHost = createWatchCompilerHostOfConfigFile({ + const mainFile: File = { + path: `${projectRoot}/index.ts`, + content: "let compiler = new Compiler(); for (let i = 0; j < 5; i++) {}" + }; + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem( + [libFile, mainFile, config], + { currentDirectory: projectRoot }), + ); + const host = createWatchCompilerHostOfConfigFileForBaseline({ configFileName: config.path, - system: host, - reportWatchStatus + system: sys, + cb, }); - createWatchProgram(compilerHost); + const existing = host.onWatchStatusChange!; + let watchedErrorCount; + host.onWatchStatusChange = (diagnostic, newLine, options, errorCount) => { + existing.call(host, diagnostic, newLine, options, errorCount); + watchedErrorCount = errorCount; + }; + const watch = createWatchProgram(host); assert.equal(watchedErrorCount, 2, "The error count was expected to be 2 for the file change"); + runWatchBaseline({ + scenario: "watchApi", + subScenario: "verify that the error count is correctly passed down to the watch status reporter", + commandLineArgs: ["--w", "--p", config.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: emptyArray, + watchOrSolution: watch + }); }); }); @@ -81,16 +106,33 @@ namespace ts.tscWatch { path: `${projectRoot}/main.ts`, content: "const x = 10;" }; - const sys = createWatchedSystem([config, mainFile, libFile]); - const watchCompilerHost = createWatchCompilerHost(config.path, {}, sys); - watchCompilerHost.setTimeout = undefined; - watchCompilerHost.clearTimeout = undefined; - const watch = createWatchProgram(watchCompilerHost); - checkProgramActualFiles(watch.getProgram().getProgram(), [mainFile.path, libFile.path]); - // Write new file - const barPath = `${projectRoot}/bar.ts`; - sys.writeFile(barPath, "const y =10;"); - checkProgramActualFiles(watch.getProgram().getProgram(), [mainFile.path, barPath, libFile.path]); + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem([config, mainFile, libFile])); + const host = createWatchCompilerHostOfConfigFileForBaseline({ + configFileName: config.path, + system: sys, + cb, + }); + host.setTimeout = undefined; + host.clearTimeout = undefined; + const watch = createWatchProgram(host); + runWatchBaseline({ + scenario: "watchApi", + subScenario: "without timesouts on host program gets updated", + commandLineArgs: ["--w", "--p", config.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: [{ + caption: "Write a file", + change: sys => sys.writeFile(`${projectRoot}/bar.ts`, "const y =10;"), + timeouts: sys => { + sys.checkTimeoutQueueLength(0); + watch.getProgram(); + } + }], + watchOrSolution: watch + }); }); }); @@ -108,139 +150,273 @@ namespace ts.tscWatch { path: `${projectRoot}/other.vue`, content: "" }; - const sys = createWatchedSystem([config, mainFile, otherFile, libFile]); - const watchCompilerHost = createWatchCompilerHost( - config.path, - { allowNonTsExtensions: true }, - sys, - /*createProgram*/ undefined, - /*reportDiagnostics*/ undefined, - /*reportWatchStatus*/ undefined, - /*watchOptionsToExtend*/ undefined, - [{ extension: ".vue", isMixedContent: true, scriptKind: ScriptKind.Deferred }] + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline( + createWatchedSystem([config, mainFile, otherFile, libFile]) ); - const watch = createWatchProgram(watchCompilerHost); - checkProgramActualFiles(watch.getProgram().getProgram(), [mainFile.path, otherFile.path, libFile.path]); - - const other2 = `${projectRoot}/other2.vue`; - sys.writeFile(other2, otherFile.content); - checkSingleTimeoutQueueLengthAndRun(sys); - checkProgramActualFiles(watch.getProgram().getProgram(), [mainFile.path, otherFile.path, libFile.path, other2]); + const host = createWatchCompilerHostOfConfigFileForBaseline({ + configFileName: config.path, + optionsToExtend: { allowNonTsExtensions: true }, + extraFileExtensions: [{ extension: ".vue", isMixedContent: true, scriptKind: ScriptKind.Deferred }], + system: sys, + cb, + }); + const watch = createWatchProgram(host); + runWatchBaseline({ + scenario: "watchApi", + subScenario: "extraFileExtensions are supported", + commandLineArgs: ["--w", "--p", config.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: [{ + caption: "Write a file", + change: sys => sys.writeFile(`${projectRoot}/other2.vue`, otherFile.content), + timeouts: checkSingleTimeoutQueueLengthAndRun, + }], + watchOrSolution: watch + }); }); }); describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticDiagnosticsBuilderProgram", () => { - function getWatch(config: File, optionsToExtend: CompilerOptions | undefined, sys: System, createProgram: CreateProgram) { - const watchCompilerHost = createWatchCompilerHost(config.path, optionsToExtend, sys, createProgram); - return createWatchProgram(watchCompilerHost); - } - - function setup(createProgram: CreateProgram, configText: string) { + function createSystem(configText: string, mainText: string) { const config: File = { path: `${projectRoot}/tsconfig.json`, content: configText }; const mainFile: File = { path: `${projectRoot}/main.ts`, - content: "export const x = 10;" + content: mainText }; const otherFile: File = { path: `${projectRoot}/other.ts`, content: "export const y = 10;" }; - const sys = createWatchedSystem([config, mainFile, otherFile, libFile]); - const watch = getWatch(config, { noEmit: true }, sys, createProgram); - return { sys, watch, mainFile, otherFile, config }; + return { + ...createBaseline(createWatchedSystem([config, mainFile, otherFile, libFile])), + config, + mainFile, + otherFile, + }; } - function verifyOutputs(sys: System, emitSys: System) { + function createWatch( + baseline: string[], + config: File, + sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles, + createProgram: CreateProgram, + optionsToExtend?: CompilerOptions, + ) { + const { cb, getPrograms } = commandLineCallbacks(sys); + baseline.push(`tsc --w${optionsToExtend?.noEmit ? " --noEmit" : ""}`); + const oldSnap = sys.snap(); + const host = createWatchCompilerHostOfConfigFileForBaseline({ + configFileName: config.path, + optionsToExtend, + createProgram, + system: sys, + cb, + }); + const watch = createWatchProgram(host); + watchBaseline({ + baseline, + getPrograms, + oldPrograms: emptyArray, + sys, + oldSnap, + }); + watch.close(); + } + + function verifyOutputs(baseline: string[], sys: System, emitSys: System) { + baseline.push("Checking if output is same as EmitAndSemanticDiagnosticsBuilderProgram::"); for (const output of [`${projectRoot}/main.js`, `${projectRoot}/main.d.ts`, `${projectRoot}/other.js`, `${projectRoot}/other.d.ts`, `${projectRoot}/tsconfig.tsbuildinfo`]) { - assert.strictEqual(sys.readFile(output), emitSys.readFile(output), `Output file text for ${output}`); + baseline.push(`Output file text for ${output} is same:: ${sys.readFile(output) === emitSys.readFile(output)}`); } + baseline.push(""); } - function verifyBuilder(config: File, sys: System, emitSys: System, createProgram: CreateProgram, createEmitProgram: CreateProgram, optionsToExtend?: CompilerOptions) { - const watch = getWatch(config, /*optionsToExtend*/ optionsToExtend, sys, createProgram); - const emitWatch = getWatch(config, /*optionsToExtend*/ optionsToExtend, emitSys, createEmitProgram); - verifyOutputs(sys, emitSys); - watch.close(); - emitWatch.close(); + function createSystemForBuilderTest(configText: string, mainText: string) { + const result = createSystem(configText, mainText); + const { sys: emitSys, baseline: emitBaseline } = createSystem(configText, mainText); + return { ...result, emitSys, emitBaseline }; + } + + function applyChangeForBuilderTest( + baseline: string[], + emitBaseline: string[], + sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles, + emitSys: TestFSWithWatch.TestServerHostTrackingWrittenFiles, + change: (sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles) => void, + caption: string + ) { + // Change file + applyChange(sys, baseline, change, caption); + applyChange(emitSys, emitBaseline, change, caption); + } + + function verifyBuilder( + baseline: string[], + emitBaseline: string[], + config: File, + sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles, + emitSys: TestFSWithWatch.TestServerHostTrackingWrittenFiles, + createProgram: CreateProgram, + optionsToExtend?: CompilerOptions) { + createWatch(baseline, config, sys, createProgram, optionsToExtend); + createWatch(emitBaseline, config, emitSys, createEmitAndSemanticDiagnosticsBuilderProgram, optionsToExtend); + verifyOutputs(baseline, sys, emitSys); } it("verifies that noEmit is handled on createSemanticDiagnosticsBuilderProgram and typechecking happens only on affected files", () => { - const { sys, watch, mainFile, otherFile } = setup(createSemanticDiagnosticsBuilderProgram, "{}"); - checkProgramActualFiles(watch.getProgram().getProgram(), [mainFile.path, otherFile.path, libFile.path]); - sys.appendFile(mainFile.path, "\n// SomeComment"); - sys.runQueuedTimeoutCallbacks(); - const program = watch.getProgram().getProgram(); - assert.deepEqual(program.getCachedSemanticDiagnostics(program.getSourceFile(mainFile.path)), []); - // Should not retrieve diagnostics for other file thats not changed - assert.deepEqual(program.getCachedSemanticDiagnostics(program.getSourceFile(otherFile.path)), /*expected*/ undefined); + const { sys, baseline, oldSnap, cb, getPrograms, config, mainFile } = createSystem("{}", "export const x = 10;"); + const host = createWatchCompilerHostOfConfigFileForBaseline({ + configFileName: config.path, + optionsToExtend: { noEmit: true }, + createProgram: createSemanticDiagnosticsBuilderProgram, + system: sys, + cb, + }); + const watch = createWatchProgram(host); + runWatchBaseline({ + scenario: "watchApi", + subScenario: "verifies that noEmit is handled on createSemanticDiagnosticsBuilderProgram", + commandLineArgs: ["--w", "--p", config.path], + sys, + baseline, + oldSnap, + getPrograms, + changes: [{ + caption: "Modify a file", + change: sys => sys.appendFile(mainFile.path, "\n// SomeComment"), + timeouts: runQueuedTimeoutCallbacks, + }], + watchOrSolution: watch + }); }); - it("noEmit with composite writes the tsbuildinfo with pending affected files correctly", () => { - const configText = JSON.stringify({ compilerOptions: { composite: true } }); - const { sys, watch, config, mainFile } = setup(createSemanticDiagnosticsBuilderProgram, configText); - const { sys: emitSys, watch: emitWatch } = setup(createEmitAndSemanticDiagnosticsBuilderProgram, configText); - verifyOutputs(sys, emitSys); + describe("noEmit with composite writes the tsbuildinfo with pending affected files correctly", () => { + let baseline: string[]; + let emitBaseline: string[]; + before(() => { + const configText = JSON.stringify({ compilerOptions: { composite: true } }); + const mainText = "export const x = 10;"; + const result = createSystemForBuilderTest(configText, mainText); + baseline = result.baseline; + emitBaseline = result.emitBaseline; + const { sys, config, mainFile, emitSys } = result; - watch.close(); - emitWatch.close(); + // No Emit + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createEmitAndSemanticDiagnosticsBuilderProgram, { noEmit: true }); - // Emit on both sys should result in same output - verifyBuilder(config, sys, emitSys, createEmitAndSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram); + // Emit on both sys should result in same output + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createEmitAndSemanticDiagnosticsBuilderProgram); - // Change file - sys.appendFile(mainFile.path, "\n// SomeComment"); - emitSys.appendFile(mainFile.path, "\n// SomeComment"); + // Change file + applyChangeForBuilderTest(baseline, emitBaseline, sys, emitSys, sys => sys.appendFile(mainFile.path, "\n// SomeComment"), "Add comment"); - // Verify noEmit results in same output - verifyBuilder(config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram, { noEmit: true }); + // Verify noEmit results in same output + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, { noEmit: true }); - // Emit on both sys should result in same output - verifyBuilder(config, sys, emitSys, createEmitAndSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram); + // Emit on both sys should result in same output + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createEmitAndSemanticDiagnosticsBuilderProgram); - // Change file - sys.appendFile(mainFile.path, "\n// SomeComment"); - emitSys.appendFile(mainFile.path, "\n// SomeComment"); + // Change file + applyChangeForBuilderTest(baseline, emitBaseline, sys, emitSys, sys => sys.appendFile(mainFile.path, "\n// SomeComment"), "Add comment"); - // Emit on both the builders should result in same files - verifyBuilder(config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram); + // Emit on both the builders should result in same files + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createSemanticDiagnosticsBuilderProgram); + }); + after(() => { + baseline = undefined!; + emitBaseline = undefined!; + }); + it("noEmit with composite writes the tsbuildinfo with pending affected files correctly", () => { + Harness.Baseline.runBaseline(`tscWatch/watchApi/noEmit-with-composite-with-semantic-builder.js`, baseline.join("\r\n")); + }); + it("baseline in createEmitAndSemanticDiagnosticsBuilderProgram:: noEmit with composite writes the tsbuildinfo with pending affected files correctly", () => { + Harness.Baseline.runBaseline(`tscWatch/watchApi/noEmit-with-composite-with-emit-builder.js`, emitBaseline.join("\r\n")); + }); }); - it("noEmitOnError with composite writes the tsbuildinfo with pending affected files correctly", () => { - const config: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { composite: true } }) - }; - const mainFile: File = { - path: `${projectRoot}/main.ts`, - content: "export const x: string = 10;" - }; - const otherFile: File = { - path: `${projectRoot}/other.ts`, - content: "export const y = 10;" - }; - const sys = createWatchedSystem([config, mainFile, otherFile, libFile]); - const emitSys = createWatchedSystem([config, mainFile, otherFile, libFile]); + describe("noEmitOnError with composite writes the tsbuildinfo with pending affected files correctly", () => { + let baseline: string[]; + let emitBaseline: string[]; + before(() => { + const configText = JSON.stringify({ compilerOptions: { composite: true, noEmitOnError: true } }); + const mainText = "export const x: string = 10;"; + const result = createSystemForBuilderTest(configText, mainText); + baseline = result.baseline; + emitBaseline = result.emitBaseline; + const { sys, config, mainFile, emitSys } = result; - // Verify noEmit results in same output - verifyBuilder(config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram, { noEmitOnError: true }); + // Verify noEmit results in same output + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createSemanticDiagnosticsBuilderProgram); - // Change file - sys.appendFile(mainFile.path, "\n// SomeComment"); - emitSys.appendFile(mainFile.path, "\n// SomeComment"); + // Change file + applyChangeForBuilderTest(baseline, emitBaseline, sys, emitSys, sys => sys.appendFile(mainFile.path, "\n// SomeComment"), "Add comment"); + + // Verify noEmit results in same output + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createSemanticDiagnosticsBuilderProgram); + + // Fix error + const fixed = "export const x = 10;"; + applyChangeForBuilderTest(baseline, emitBaseline, sys, emitSys, sys => sys.writeFile(mainFile.path, fixed), "Fix error"); - // Verify noEmit results in same output - verifyBuilder(config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram, { noEmitOnError: true }); + // Emit on both the builders should result in same files + verifyBuilder(baseline, emitBaseline, config, sys, emitSys, createSemanticDiagnosticsBuilderProgram); + }); - // Fix error - const fixed = "export const x = 10;"; - sys.appendFile(mainFile.path, fixed); - emitSys.appendFile(mainFile.path, fixed); + it("noEmitOnError with composite writes the tsbuildinfo with pending affected files correctly", () => { + Harness.Baseline.runBaseline(`tscWatch/watchApi/noEmitOnError-with-composite-with-semantic-builder.js`, baseline.join("\r\n")); + }); + it("baseline in createEmitAndSemanticDiagnosticsBuilderProgram:: noEmitOnError with composite writes the tsbuildinfo with pending affected files correctly", () => { + Harness.Baseline.runBaseline(`tscWatch/watchApi/noEmitOnError-with-composite-with-emit-builder.js`, emitBaseline.join("\r\n")); + }); + }); - // Emit on both the builders should result in same files - verifyBuilder(config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram, { noEmitOnError: true }); + it("SemanticDiagnosticsBuilderProgram emitDtsOnly does not update affected files pending emit", () => { + // Initial + const { sys, baseline, config, mainFile } = createSystem(JSON.stringify({ compilerOptions: { composite: true, noEmitOnError: true } }), "export const x: string = 10;"); + createWatch(baseline, config, sys, createSemanticDiagnosticsBuilderProgram); + + // Fix error and emit + applyChange(sys, baseline, sys => sys.writeFile(mainFile.path, "export const x = 10;"), "Fix error"); + + const { cb, getPrograms } = commandLineCallbacks(sys); + const oldSnap = sys.snap(); + const reportDiagnostic = createDiagnosticReporter(sys, /*pretty*/ true); + const reportWatchStatus = createWatchStatusReporter(sys, /*pretty*/ true); + const host = createWatchCompilerHostOfConfigFile({ + configFileName: config.path, + createProgram: createSemanticDiagnosticsBuilderProgram, + system: sys, + reportDiagnostic, + reportWatchStatus, + }); + host.afterProgramCreate = program => { + const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics()); + diagnostics.forEach(reportDiagnostic); + // Buildinfo should still have affectedFilesPendingEmit since we are only emitting dts files + program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDts*/ true); + reportWatchStatus( + createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(diagnostics.length), diagnostics.length), + sys.newLine, + program.getCompilerOptions(), + diagnostics.length + ); + cb(program); + }; + createWatchProgram(host); + watchBaseline({ + baseline, + getPrograms, + oldPrograms: emptyArray, + sys, + oldSnap, + }); + Harness.Baseline.runBaseline(`tscWatch/watchApi/semantic-builder-emitOnlyDts.js`, baseline.join("\r\n")); }); }); @@ -282,9 +458,10 @@ namespace ts.tscWatch { }; const system = createWatchedSystem([config1, class1, class1Dts, config2, class2, libFile]); const baseline = createBaseline(system); - const compilerHost = createWatchCompilerHostOfConfigFile({ - configFileName: config2.path, + const compilerHost = createWatchCompilerHostOfConfigFileForBaseline({ + cb: baseline.cb, system, + configFileName: config2.path, optionsToExtend: { extendedDiagnostics: true } }); compilerHost.useSourceOfProjectReferenceRedirect = useSourceOfProjectReferenceRedirect; @@ -312,7 +489,6 @@ namespace ts.tscWatch { subScenario: "when new file is added to the referenced project with host implementing getParsedCommandLine", commandLineArgs: ["--w", "-p", config2.path, "--extendedDiagnostics"], ...baseline, - getPrograms: () => [[watch.getCurrentProgram().getProgram(), watch.getCurrentProgram()]], changes: [ { caption: "Add class3 to project1", @@ -344,7 +520,6 @@ namespace ts.tscWatch { subScenario: "when new file is added to the referenced project with host implementing getParsedCommandLine without implementing useSourceOfProjectReferenceRedirect", commandLineArgs: ["--w", "-p", config2.path, "--extendedDiagnostics"], ...baseline, - getPrograms: () => [[watch.getCurrentProgram().getProgram(), watch.getCurrentProgram()]], changes: [ { caption: "Add class3 to project1", diff --git a/src/testRunner/unittests/tsserver/auxiliaryProject.ts b/src/testRunner/unittests/tsserver/auxiliaryProject.ts new file mode 100644 index 0000000000000..4b5f865c19aeb --- /dev/null +++ b/src/testRunner/unittests/tsserver/auxiliaryProject.ts @@ -0,0 +1,47 @@ +namespace ts.projectSystem { + const aTs: File = { + path: "/a.ts", + content: `import { B } from "./b";` + }; + const bDts: File = { + path: "/b.d.ts", + content: `export declare class B {}` + }; + const bJs: File = { + path: "/b.js", + content: `export class B {}` + }; + describe("unittests:: tsserver:: auxiliaryProject", () => { + it("AuxiliaryProject does not remove scrips from InferredProject", () => { + const host = createServerHost([aTs, bDts, bJs]); + const session = createSession(host); + const projectService = session.getProjectService(); + openFilesForSession([aTs], session); + + // Open file is in inferred project + checkNumberOfInferredProjects(projectService, 1); + const inferredProject = projectService.inferredProjects[0]; + + // getNoDtsResolutionProject will create an AuxiliaryProject with a.ts and b.js + const auxProject = inferredProject.getNoDtsResolutionProject([aTs.path]); + auxProject.updateGraph(); + + // b.js ScriptInfo is now available because it's contained by the AuxiliaryProject. + // The AuxiliaryProject should never be the default project for anything, so + // the ScriptInfo should still report being an orphan, and getting its default + // project should throw. + const bJsScriptInfo = Debug.checkDefined(projectService.getScriptInfo(bJs.path)); + assert(bJsScriptInfo.isOrphan()); + assert(bJsScriptInfo.isContainedByBackgroundProject()); + assert.deepEqual(bJsScriptInfo.containingProjects, [auxProject]); + assert.throws(() => bJsScriptInfo.getDefaultProject()); + + // When b.js is opened in the editor, it should be put into an InferredProject + // even though it's still contained by the AuxiliaryProject. + openFilesForSession([bJs], session); + assert(!bJsScriptInfo.isOrphan()); + assert(bJsScriptInfo.isContainedByBackgroundProject()); + assert.equal(bJsScriptInfo.getDefaultProject().projectKind, server.ProjectKind.Inferred); + }); + }); +} diff --git a/src/testRunner/unittests/tsserver/completions.ts b/src/testRunner/unittests/tsserver/completions.ts index ab84366efc933..3da4c8fe8ca28 100644 --- a/src/testRunner/unittests/tsserver/completions.ts +++ b/src/testRunner/unittests/tsserver/completions.ts @@ -52,6 +52,7 @@ namespace ts.projectSystem { assert.isString(exportMapKey); delete (response?.entries[0].data as any).exportMapKey; assert.deepEqual(response, { + flags: CompletionInfoFlags.MayIncludeAutoImports, isGlobalCompletion: true, isIncomplete: undefined, isMemberCompletion: false, diff --git a/src/testRunner/unittests/tsserver/completionsIncomplete.ts b/src/testRunner/unittests/tsserver/completionsIncomplete.ts index ae9c53cbc9289..0bdef496d1de1 100644 --- a/src/testRunner/unittests/tsserver/completionsIncomplete.ts +++ b/src/testRunner/unittests/tsserver/completionsIncomplete.ts @@ -135,7 +135,7 @@ namespace ts.projectSystem { typeToTriggerCompletions(indexFile.path, "s", completions => { const sigint = completions.entries.find(e => e.name === "SIGINT"); assert(sigint); - assert(!(sigint!.data as any).moduleSpecifier); + assert(!(sigint.data as any).moduleSpecifier); }) .continueTyping("i", completions => { const sigint = completions.entries.find(e => e.name === "SIGINT"); @@ -255,7 +255,7 @@ namespace ts.projectSystem { assert(details[0]); assert(details[0].codeActions); - assert(details[0].codeActions![0].changes[0].textChanges[0].newText.includes(`"${(entry.data as any).moduleSpecifier}"`)); + assert(details[0].codeActions[0].changes[0].textChanges[0].newText.includes(`"${(entry.data as any).moduleSpecifier}"`)); return details; } } diff --git a/src/testRunner/unittests/tsserver/metadataInResponse.ts b/src/testRunner/unittests/tsserver/metadataInResponse.ts index 2ca20ff4046a9..8ea9d5ff7f742 100644 --- a/src/testRunner/unittests/tsserver/metadataInResponse.ts +++ b/src/testRunner/unittests/tsserver/metadataInResponse.ts @@ -77,6 +77,7 @@ namespace ts.projectSystem { command: protocol.CommandTypes.CompletionInfo, arguments: completionRequestArgs }, { + flags: 0, isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, diff --git a/src/testRunner/unittests/tsserver/moduleSpecifierCache.ts b/src/testRunner/unittests/tsserver/moduleSpecifierCache.ts index 60e584882a0d2..e86cd6a694e1b 100644 --- a/src/testRunner/unittests/tsserver/moduleSpecifierCache.ts +++ b/src/testRunner/unittests/tsserver/moduleSpecifierCache.ts @@ -39,7 +39,7 @@ namespace ts.projectSystem { describe("unittests:: tsserver:: moduleSpecifierCache", () => { it("caches importability within a file", () => { const { moduleSpecifierCache } = setup(); - assert.isTrue(moduleSpecifierCache.get(bTs.path as Path, aTs.path as Path, {}, {})?.isAutoImportable); + assert.isFalse(moduleSpecifierCache.get(bTs.path as Path, aTs.path as Path, {}, {})?.isBlockedByPackageJsonDependencies); }); it("caches module specifiers within a file", () => { @@ -54,7 +54,7 @@ namespace ts.projectSystem { isRedirect: false }], moduleSpecifiers: ["mobx"], - isAutoImportable: true, + isBlockedByPackageJsonDependencies: false, }); }); @@ -72,7 +72,7 @@ namespace ts.projectSystem { const { host, moduleSpecifierCache } = setup(); host.writeFile("/src/a2.ts", aTs.content); host.runQueuedTimeoutCallbacks(); - assert.isTrue(moduleSpecifierCache.get(bTs.path as Path, aTs.path as Path, {}, {})?.isAutoImportable); + assert.isFalse(moduleSpecifierCache.get(bTs.path as Path, aTs.path as Path, {}, {})?.isBlockedByPackageJsonDependencies); }); it("invalidates the cache when symlinks are added or removed", () => { diff --git a/src/testRunner/unittests/tsserver/projectReferences.ts b/src/testRunner/unittests/tsserver/projectReferences.ts index bae075912be5f..ba4604be5aabf 100644 --- a/src/testRunner/unittests/tsserver/projectReferences.ts +++ b/src/testRunner/unittests/tsserver/projectReferences.ts @@ -1278,8 +1278,7 @@ bar;` const files = [solnConfig, sharedConfig, sharedIndex, sharedPackage, appConfig, appBar, appIndex, sharedSymlink, libFile]; const host = createServerHost(files); if (built) { - const solutionBuilder = tscWatch.createSolutionBuilder(host, [solnConfig.path], {}); - solutionBuilder.build(); + tscWatch.solutionBuildWithBaseline(host, [solnConfig.path]); host.clearOutput(); } const session = createSession(host, { logger: createLoggerWithInMemoryLogs() }); diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types index 553563168a867..5e79973b27b15 100644 --- a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types +++ b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types @@ -1,6 +1,6 @@ === tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts === type T = { x : number } ->T : T +>T : { x: number; } >x : number export interface I { diff --git a/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt index b64781a4873ba..4d680b362ace9 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts(4,19): error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts(4,19): error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts(4,19 strSet.add('World') for (const str of strSet) { } ~~~~~~ -!!! error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. \ No newline at end of file +!!! error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt index 1fde67722db30..e815c53e2f3f8 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts (1 errors) ==== var union: string | Set for (const e of union) { } ~~~~~ -!!! error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. \ No newline at end of file +!!! error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/abstractClassUnionInstantiation.types b/tests/baselines/reference/abstractClassUnionInstantiation.types index 969f0b85c44a5..1f1458a7283ed 100644 --- a/tests/baselines/reference/abstractClassUnionInstantiation.types +++ b/tests/baselines/reference/abstractClassUnionInstantiation.types @@ -14,17 +14,17 @@ abstract class AbstractB { b: string; } >b : string type Abstracts = typeof AbstractA | typeof AbstractB; ->Abstracts : Abstracts +>Abstracts : typeof AbstractA | typeof AbstractB >AbstractA : typeof AbstractA >AbstractB : typeof AbstractB type Concretes = typeof ConcreteA | typeof ConcreteB; ->Concretes : Concretes +>Concretes : typeof ConcreteA | typeof ConcreteB >ConcreteA : typeof ConcreteA >ConcreteB : typeof ConcreteB type ConcretesOrAbstracts = Concretes | Abstracts; ->ConcretesOrAbstracts : ConcretesOrAbstracts +>ConcretesOrAbstracts : Abstracts | Concretes declare const cls1: ConcretesOrAbstracts; >cls1 : ConcretesOrAbstracts diff --git a/tests/baselines/reference/accessorBodyInTypeContext.types b/tests/baselines/reference/accessorBodyInTypeContext.types index ad04c25524d88..41a1a234e1bab 100644 --- a/tests/baselines/reference/accessorBodyInTypeContext.types +++ b/tests/baselines/reference/accessorBodyInTypeContext.types @@ -1,6 +1,6 @@ === tests/cases/compiler/accessorBodyInTypeContext.ts === type A = { ->A : A +>A : { readonly foo: number; } get foo() { return 0 } >foo : number @@ -9,7 +9,7 @@ type A = { }; type B = { ->B : B +>B : { foo: any; } set foo(v: any) { } >foo : any diff --git a/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.types b/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.types index 6377ed3cd7315..8b580c9cb3268 100644 --- a/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.types +++ b/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.types @@ -8,10 +8,10 @@ type ExtendedMapper = (name : strin >args : ArgsT type a = ExtendedMapper; ->a : a +>a : (name: string, mixed: any, args_0: any) => any type b = ExtendedMapper; ->b : b +>b : (name: string, mixed: any, ...args: any[]) => any type test = a extends b ? "y" : "n" >test : "y" @@ -32,10 +32,10 @@ type ExtendedMapper1 = ( ); type a1 = ExtendedMapper1; ->a1 : a1 +>a1 : (name: string, mixed: any, args_0: any) => any type b1 = ExtendedMapper1; ->b1 : b1 +>b1 : (name: string, mixed: any, ...args: any[]) => any type test1 = a1 extends b1 ? "y" : "n" >test1 : "y" @@ -56,10 +56,10 @@ type ExtendedMapper2 = ( ); type a2 = ExtendedMapper2; ->a2 : a2 +>a2 : (name: string, mixed: any, args_0: any) => any type b2 = ExtendedMapper2; ->b2 : b2 +>b2 : (name: string, mixed: any, ...args: any[]) => any type test2 = a2 extends b2 ? "y" : "n" >test2 : "y" @@ -69,13 +69,13 @@ let check2: test2 = "y"; >"y" : "y" type a3 = (name: string, mixed: any, args_0: any) => any ->a3 : a3 +>a3 : (name: string, mixed: any, args_0: any) => any >name : string >mixed : any >args_0 : any type b3 = (name: string, mixed: any, ...args: any[]) => any ->b3 : b3 +>b3 : (name: string, mixed: any, ...args: any[]) => any >name : string >mixed : any >args : any[] diff --git a/tests/baselines/reference/anyMappedTypesError.types b/tests/baselines/reference/anyMappedTypesError.types index 876d29194414f..e30f65d142ec1 100644 --- a/tests/baselines/reference/anyMappedTypesError.types +++ b/tests/baselines/reference/anyMappedTypesError.types @@ -1,4 +1,4 @@ === tests/cases/compiler/anyMappedTypesError.ts === type Foo = {[P in "bar"]}; ->Foo : Foo +>Foo : { bar: any; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 9ea997539f55f..f7e45674ac056 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2172,7 +2172,9 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export interface WriteFileCallbackData { + } + export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -2394,7 +2396,6 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, - NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2892,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2901,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3073,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4817,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6434,7 +6435,18 @@ declare namespace ts { argumentIndex: number; argumentCount: number; } + enum CompletionInfoFlags { + None = 0, + MayIncludeAutoImports = 1, + IsImportStatementCompletion = 2, + IsContinuation = 4, + ResolvedModuleSpecifiers = 8, + ResolvedModuleSpecifiersBeyondLimit = 16, + MayIncludeMethodSnippets = 32 + } interface CompletionInfo { + /** For performance telemetry. */ + flags?: CompletionInfoFlags; /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; @@ -6810,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6829,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. @@ -7039,6 +7051,7 @@ declare namespace ts.server.protocol { Rename = "rename", Saveto = "saveto", SignatureHelp = "signatureHelp", + FindSourceDefinition = "findSourceDefinition", Status = "status", TypeDefinition = "typeDefinition", ProjectInfo = "projectInfo", @@ -7658,6 +7671,9 @@ declare namespace ts.server.protocol { interface DefinitionAndBoundSpanRequest extends FileLocationRequest { readonly command: CommandTypes.DefinitionAndBoundSpan; } + interface FindSourceDefinitionRequest extends FileLocationRequest { + readonly command: CommandTypes.FindSourceDefinition; + } interface DefinitionAndBoundSpanResponse extends Response { readonly body: DefinitionInfoAndBoundSpan; } @@ -8818,6 +8834,7 @@ declare namespace ts.server.protocol { body?: CompletionInfo; } interface CompletionInfo { + readonly flags?: number; readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; @@ -9906,7 +9923,8 @@ declare namespace ts.server { Inferred = 0, Configured = 1, External = 2, - AutoImportProvider = 3 + AutoImportProvider = 3, + Auxiliary = 4 } function allRootFilesAreJsOrDts(project: Project): boolean; function allFilesAreJsOrDts(project: Project): boolean; @@ -10641,6 +10659,7 @@ declare namespace ts.server { private getDefinition; private mapDefinitionInfoLocations; private getDefinitionAndBoundSpan; + private findSourceDefinition; private getEmitOutput; private mapJSDocTagInfo; private mapDisplayParts; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 45eed1b64845b..fb0a5a0c1e756 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2172,7 +2172,9 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export interface WriteFileCallbackData { + } + export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -2394,7 +2396,6 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, - NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2892,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2901,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3073,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4817,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6434,7 +6435,18 @@ declare namespace ts { argumentIndex: number; argumentCount: number; } + enum CompletionInfoFlags { + None = 0, + MayIncludeAutoImports = 1, + IsImportStatementCompletion = 2, + IsContinuation = 4, + ResolvedModuleSpecifiers = 8, + ResolvedModuleSpecifiersBeyondLimit = 16, + MayIncludeMethodSnippets = 32 + } interface CompletionInfo { + /** For performance telemetry. */ + flags?: CompletionInfoFlags; /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; @@ -6810,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6829,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. diff --git a/tests/baselines/reference/argumentsAsPropertyName.types b/tests/baselines/reference/argumentsAsPropertyName.types index 86bbd8474702c..b5753c3da720f 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.types +++ b/tests/baselines/reference/argumentsAsPropertyName.types @@ -1,7 +1,7 @@ === tests/cases/compiler/argumentsAsPropertyName.ts === // target: es5 type MyType = { ->MyType : MyType +>MyType : { arguments: Array; } arguments: Array >arguments : string[] diff --git a/tests/baselines/reference/arrayDestructuringInSwitch1.types b/tests/baselines/reference/arrayDestructuringInSwitch1.types index dfb06774cec16..56d48f6a30075 100644 --- a/tests/baselines/reference/arrayDestructuringInSwitch1.types +++ b/tests/baselines/reference/arrayDestructuringInSwitch1.types @@ -1,9 +1,9 @@ === tests/cases/compiler/arrayDestructuringInSwitch1.ts === export type Expression = BooleanLogicExpression | 'true' | 'false'; ->Expression : Expression +>Expression : BooleanLogicExpression | "true" | "false" export type BooleanLogicExpression = ['and', ...Expression[]] | ['not', Expression]; ->BooleanLogicExpression : BooleanLogicExpression +>BooleanLogicExpression : ["and", ...Expression[]] | ["not", Expression] export function evaluate(expression: Expression): boolean { >evaluate : (expression: Expression) => boolean diff --git a/tests/baselines/reference/arrayDestructuringInSwitch2.types b/tests/baselines/reference/arrayDestructuringInSwitch2.types index 727a2fc68ebc3..62b0999fcbd6b 100644 --- a/tests/baselines/reference/arrayDestructuringInSwitch2.types +++ b/tests/baselines/reference/arrayDestructuringInSwitch2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/arrayDestructuringInSwitch2.ts === type X = { kind: "a", a: [1] } | { kind: "b", a: [] } ->X : X +>X : { kind: "a"; a: [1]; } | { kind: "b"; a: []; } >kind : "a" >a : [1] >kind : "b" diff --git a/tests/baselines/reference/arrayFakeFlatNoCrashInferenceDeclarations.types b/tests/baselines/reference/arrayFakeFlatNoCrashInferenceDeclarations.types index fd8dccc975c77..692e007dd92ba 100644 --- a/tests/baselines/reference/arrayFakeFlatNoCrashInferenceDeclarations.types +++ b/tests/baselines/reference/arrayFakeFlatNoCrashInferenceDeclarations.types @@ -19,7 +19,7 @@ type BadFlatArray = {obj: { >1 : 1 declare function flat( ->flat : (arr: A, depth?: D | undefined) => BadFlatArray[] +>flat : (arr: A, depth?: D) => BadFlatArray[] arr: A, >arr : A diff --git a/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.types b/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.types index aa4b32692b10d..9384922fa7a29 100644 --- a/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.types +++ b/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.types @@ -18,7 +18,7 @@ interface Dog { } type Animal = Cat | Dog; ->Animal : Animal +>Animal : Cat | Dog declare function assertEqual(value: any, type: T): asserts value is T; >assertEqual : (value: any, type: T) => asserts value is T diff --git a/tests/baselines/reference/assertionTypePredicates1.types b/tests/baselines/reference/assertionTypePredicates1.types index e72b3077c9b95..064cf6066f4dd 100644 --- a/tests/baselines/reference/assertionTypePredicates1.types +++ b/tests/baselines/reference/assertionTypePredicates1.types @@ -270,7 +270,7 @@ namespace Debug { >Debug : typeof Debug export declare function assert(value: unknown, message?: string): asserts value; ->assert : (value: unknown, message?: string | undefined) => asserts value +>assert : (value: unknown, message?: string) => asserts value >value : unknown >message : string | undefined diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types index cc88ed30c0738..58784a84667ad 100644 --- a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types @@ -6,12 +6,12 @@ namespace Example1 { >Example1 : typeof Example1 type S = { done: boolean, value: number }; ->S : S +>S : { done: boolean; value: number; } >done : boolean >value : number type T = ->T : T +>T : { done: true; value: number; } | { done: false; value: number; } | { done: true, value: number } // T0 >done : true @@ -42,12 +42,12 @@ namespace Example2 { >Example2 : typeof Example2 type S = { a: 0 | 2, b: 4 }; ->S : S +>S : { a: 0 | 2; b: 4; } >a : 0 | 2 >b : 4 type T = { a: 0, b: 1 | 4 } // T0 ->T : T +>T : { a: 0; b: 1 | 4; } | { a: 1; b: 2; } | { a: 2; b: 3 | 4; } >a : 0 >b : 4 | 1 @@ -78,12 +78,12 @@ namespace Example3 { >Example3 : typeof Example3 type S = { a: 0 | 2, b: 4 }; ->S : S +>S : { a: 0 | 2; b: 4; } >a : 0 | 2 >b : 4 type T = { a: 0, b: 1 | 4 } // T0 ->T : T +>T : { a: 0; b: 1 | 4; } | { a: 1; b: 2 | 4; } | { a: 2; b: 3; } >a : 0 >b : 4 | 1 @@ -115,12 +115,12 @@ namespace Example4 { >Example4 : typeof Example4 type S = { a: 0 | 2, b: 4 }; ->S : S +>S : { a: 0 | 2; b: 4; } >a : 0 | 2 >b : 4 type T = { a: 0, b: 1 | 4 } // T0 ->T : T +>T : { a: 0; b: 1 | 4; } | { a: 1; b: 2; } | { a: 2; b: 3 | 4; c: string; } >a : 0 >b : 4 | 1 @@ -155,16 +155,16 @@ namespace Example5 { // 3 discriminant properties with 3 types a piece // is 27 possible combinations. type N = 0 | 1 | 2; ->N : N +>N : 0 | 2 | 1 type S = { a: N, b: N, c: N }; ->S : S +>S : { a: N; b: N; c: N; } >a : N >b : N >c : N type T = { a: 0, b: N, c: N } ->T : T +>T : { a: 0; b: N; c: N; } | { a: 1; b: N; c: N; } | { a: 2; b: N; c: N; } | { a: N; b: 0; c: N; } | { a: N; b: 1; c: N; } | { a: N; b: 2; c: N; } | { a: N; b: N; c: 0; } | { a: N; b: N; c: 1; } | { a: N; b: N; c: 2; } >a : 0 >b : N >c : N @@ -228,7 +228,7 @@ namespace GH14865 { >GH14865 : typeof GH14865 type Style1 = { ->Style1 : Style1 +>Style1 : { type: "A"; data: string; } | { type: "B"; data: string; } type: "A"; >type : "A" @@ -246,7 +246,7 @@ namespace GH14865 { }; type Style2 = { ->Style2 : Style2 +>Style2 : { type: "A" | "B"; data: string; } type: "A" | "B"; >type : "A" | "B" @@ -322,10 +322,10 @@ namespace GH12052 { >type : "categorical" type IAxis = ILinearAxis | ICategoricalAxis; ->IAxis : IAxis +>IAxis : ILinearAxis | ICategoricalAxis type IAxisType = "linear" | "categorical"; ->IAxisType : IAxisType +>IAxisType : "linear" | "categorical" function getAxisType(): IAxisType { >getAxisType : () => IAxisType @@ -381,10 +381,10 @@ namespace GH18421 { } type ThingType = 'one' | 'two'; ->ThingType : ThingType +>ThingType : "one" | "two" type Thing = ThingTypeOne | ThingTypeTwo; ->Thing : Thing +>Thing : ThingTypeOne | ThingTypeTwo function makeNewThing(thingType: ThingType): Thing { >makeNewThing : (thingType: ThingType) => Thing @@ -406,7 +406,7 @@ namespace GH15907 { >GH15907 : typeof GH15907 type Action = { type: 'activate' } | { type: 'disactivate' }; ->Action : Action +>Action : { type: 'activate'; } | { type: 'disactivate'; } >type : "activate" >type : "disactivate" @@ -445,7 +445,7 @@ namespace GH20889 { >type : "A2" } type AU = A1 | A2; ->AU : AU +>AU : A1 | A2 function foo(obj1: AU) { >foo : (obj1: AU) => void @@ -470,10 +470,10 @@ namespace GH39357 { >GH39357 : typeof GH39357 type A = ["a", number] | ["b", number] | ["c", string]; ->A : A +>A : ["a", number] | ["b", number] | ["c", string] type B = "a" | "b" | "c"; ->B : B +>B : "a" | "b" | "c" declare const b: B; >b : B diff --git a/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types b/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types index 15a26ac4a9a2f..a5b9c879c7580 100644 --- a/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types +++ b/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types @@ -64,7 +64,7 @@ g(async v => v ? "contextuallyTypable" : Promise.reject()); >reject : (reason?: any) => Promise type MyCallback = (thing: string) => void; ->MyCallback : MyCallback +>MyCallback : (thing: string) => void >thing : string declare function h(cb: (v: boolean) => MyCallback | PromiseLike): void; diff --git a/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.types b/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.types index 33ccf9c331fcc..f67fe49a61fb0 100644 --- a/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.types +++ b/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.types @@ -75,7 +75,7 @@ declare function resolve2(value: T): Windows.Foundation.IPromise; >Foundation : any async function sample2(x?: number) { ->sample2 : (x?: number | undefined) => Promise +>sample2 : (x?: number) => Promise >x : number | undefined let x1 = await resolve1(x); diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt index 0c8ac2b8ec9bd..f97a066c8c80d 100644 --- a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt +++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt @@ -12,8 +12,8 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await' tests/cases/compiler/awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. tests/cases/compiler/awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/compiler/awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/compiler/awaitInNonAsyncFunction.ts (16 errors) ==== @@ -97,7 +97,7 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level ' for await (const _ of []); ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. await null; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/awaitedType.types b/tests/baselines/reference/awaitedType.types index 9bca225ef3de3..5af5babaedf12 100644 --- a/tests/baselines/reference/awaitedType.types +++ b/tests/baselines/reference/awaitedType.types @@ -9,7 +9,7 @@ type T3 = Awaited>; >T3 : number type T4 = Awaited>; ->T4 : T4 +>T4 : string | number type T5 = Awaited<{ then: number }>; >T5 : { then: number; } diff --git a/tests/baselines/reference/awaitedTypeStrictNull.types b/tests/baselines/reference/awaitedTypeStrictNull.types index 574161fa592e4..e3deb7d2247df 100644 --- a/tests/baselines/reference/awaitedTypeStrictNull.types +++ b/tests/baselines/reference/awaitedTypeStrictNull.types @@ -9,7 +9,7 @@ type T3 = Awaited>; >T3 : number type T4 = Awaited>; ->T4 : T4 +>T4 : string | number type T5 = Awaited<{ then: number }>; >T5 : { then: number; } diff --git a/tests/baselines/reference/booleanLiteralTypes1.types b/tests/baselines/reference/booleanLiteralTypes1.types index f40f964eacc0b..4de330f57ae6d 100644 --- a/tests/baselines/reference/booleanLiteralTypes1.types +++ b/tests/baselines/reference/booleanLiteralTypes1.types @@ -1,11 +1,11 @@ === tests/cases/conformance/types/literal/booleanLiteralTypes1.ts === type A1 = true | false; ->A1 : A1 +>A1 : boolean >true : true >false : false type A2 = false | true; ->A2 : A2 +>A2 : boolean >false : false >true : true @@ -244,7 +244,7 @@ function f13(x: true | false) { } type Item = ->Item : Item +>Item : { kind: true; a: string; } | { kind: false; b: string; } { kind: true, a: string } | >kind : true diff --git a/tests/baselines/reference/booleanLiteralTypes2.types b/tests/baselines/reference/booleanLiteralTypes2.types index 16323492d7a72..484d83fefd889 100644 --- a/tests/baselines/reference/booleanLiteralTypes2.types +++ b/tests/baselines/reference/booleanLiteralTypes2.types @@ -1,11 +1,11 @@ === tests/cases/conformance/types/literal/booleanLiteralTypes2.ts === type A1 = true | false; ->A1 : A1 +>A1 : boolean >true : true >false : false type A2 = false | true; ->A2 : A2 +>A2 : boolean >false : false >true : true @@ -244,7 +244,7 @@ function f13(x: true | false) { } type Item = ->Item : Item +>Item : { kind: true; a: string; } | { kind: false; b: string; } { kind: true, a: string } | >kind : true diff --git a/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.types b/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.types index d30986c385910..77b32edaf0acd 100644 --- a/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.types +++ b/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.types @@ -10,7 +10,7 @@ interface B { isIt: false; value: number; } >value : number type C = A | B; ->C : C +>C : A | B const isIt = Math.random() > 0.5; >isIt : boolean @@ -50,7 +50,7 @@ const cc: C = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; >123 : 123 type ComponentProps = ->ComponentProps : ComponentProps +>ComponentProps : { optionalBool: true; mandatoryFn: () => void; } | { optionalBool: false; } | { optionalBool: true; diff --git a/tests/baselines/reference/callWithSpread4.types b/tests/baselines/reference/callWithSpread4.types index 5caef4eb70173..5d1a4a4de3065 100644 --- a/tests/baselines/reference/callWithSpread4.types +++ b/tests/baselines/reference/callWithSpread4.types @@ -1,14 +1,14 @@ === tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts === type R = { a: number } ->R : R +>R : { a: number; } >a : number type W = { b: number } ->W : W +>W : { b: number; } >b : number type RW = { a: number, b: number } ->RW : RW +>RW : { a: number; b: number; } >a : number >b : number diff --git a/tests/baselines/reference/callsOnComplexSignatures.types b/tests/baselines/reference/callsOnComplexSignatures.types index a255300662666..192c64474400f 100644 --- a/tests/baselines/reference/callsOnComplexSignatures.types +++ b/tests/baselines/reference/callsOnComplexSignatures.types @@ -110,7 +110,7 @@ function test3(items: string[] | number[]) { } function test4( ->test4 : (arg1: ((...objs: { x: number;}[]) => number) | ((...objs: { y: number;}[]) => number), arg2: ((a: { x: number;}, b: object) => number) | ((a: object, b: { x: number;}) => number), arg3: ((a: { x: number;}, ...objs: { y: number;}[]) => number) | ((...objs: { x: number;}[]) => number), arg4: ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((a?: { y: number; } | undefined) => number), arg5: ((a?: { x: number; } | undefined, ...b: { x: number;}[]) => number) | ((a?: { y: number; } | undefined) => number), arg6: ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((...a: { y: number;}[]) => number)) => void +>test4 : (arg1: ((...objs: { x: number;}[]) => number) | ((...objs: { y: number;}[]) => number), arg2: ((a: { x: number;}, b: object) => number) | ((a: object, b: { x: number;}) => number), arg3: ((a: { x: number;}, ...objs: { y: number;}[]) => number) | ((...objs: { x: number;}[]) => number), arg4: ((a?: { x: number;}, b?: { x: number;}) => number) | ((a?: { y: number;}) => number), arg5: ((a?: { x: number;}, ...b: { x: number;}[]) => number) | ((a?: { y: number;}) => number), arg6: ((a?: { x: number;}, b?: { x: number;}) => number) | ((...a: { y: number;}[]) => number)) => void arg1: ((...objs: {x: number}[]) => number) | ((...objs: {y: number}[]) => number), >arg1 : ((...objs: { x: number;}[]) => number) | ((...objs: { y: number;}[]) => number) @@ -138,7 +138,7 @@ function test4( >x : number arg4: ((a?: {x: number}, b?: {x: number}) => number) | ((a?: {y: number}) => number), ->arg4 : ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((a?: { y: number; } | undefined) => number) +>arg4 : ((a?: { x: number;}, b?: { x: number;}) => number) | ((a?: { y: number;}) => number) >a : { x: number; } | undefined >x : number >b : { x: number; } | undefined @@ -147,7 +147,7 @@ function test4( >y : number arg5: ((a?: {x: number}, ...b: {x: number}[]) => number) | ((a?: {y: number}) => number), ->arg5 : ((a?: { x: number; } | undefined, ...b: { x: number;}[]) => number) | ((a?: { y: number; } | undefined) => number) +>arg5 : ((a?: { x: number;}, ...b: { x: number;}[]) => number) | ((a?: { y: number;}) => number) >a : { x: number; } | undefined >x : number >b : { x: number; }[] @@ -156,7 +156,7 @@ function test4( >y : number arg6: ((a?: {x: number}, b?: {x: number}) => number) | ((...a: {y: number}[]) => number), ->arg6 : ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((...a: { y: number;}[]) => number) +>arg6 : ((a?: { x: number;}, b?: { x: number;}) => number) | ((...a: { y: number;}[]) => number) >a : { x: number; } | undefined >x : number >b : { x: number; } | undefined @@ -339,7 +339,7 @@ function test5() { // Pair of non-like intrinsics function render(url?: string): React.ReactNode { ->render : (url?: string | undefined) => React.ReactNode +>render : (url?: string) => React.ReactNode >url : string | undefined >React : any diff --git a/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types index 0b18a2d650270..c59089053583e 100644 --- a/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types +++ b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types @@ -21,7 +21,7 @@ import { TypeA } from './type-a'; >TypeA : any export type TypeB = MergeTypeB : TypeB +>TypeB : TypeA & { b: string; } b: string; >b : string @@ -29,7 +29,7 @@ export type TypeB = Merge; === tests/cases/compiler/Uppercased_Dir/src/type-a.ts === export type TypeA = { ->TypeA : TypeA +>TypeA : { a: string; } a: string; >a : string diff --git a/tests/baselines/reference/circularAccessorAnnotations.types b/tests/baselines/reference/circularAccessorAnnotations.types index 1945fdc51092a..9a4041b526ca0 100644 --- a/tests/baselines/reference/circularAccessorAnnotations.types +++ b/tests/baselines/reference/circularAccessorAnnotations.types @@ -35,14 +35,14 @@ declare const c3: { } type T1 = { ->T1 : T1 +>T1 : { readonly foo: any; } get foo(): T1["foo"]; >foo : any } type T2 = { ->T2 : T2 +>T2 : { foo: any; } set foo(value: T2["foo"]); >foo : any @@ -50,7 +50,7 @@ type T2 = { } type T3 = { ->T3 : T3 +>T3 : { foo: string; } get foo(): string; >foo : string diff --git a/tests/baselines/reference/circularIndexedAccessErrors.types b/tests/baselines/reference/circularIndexedAccessErrors.types index 9ffde7a1f3c12..5085b290b690b 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.types +++ b/tests/baselines/reference/circularIndexedAccessErrors.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts === type T1 = { ->T1 : T1 +>T1 : { x: any; } x: T1["x"]; // Error >x : any diff --git a/tests/baselines/reference/circularOptionalityRemoval.types b/tests/baselines/reference/circularOptionalityRemoval.types index 5783b24a6c379..f35bd580699b7 100644 --- a/tests/baselines/reference/circularOptionalityRemoval.types +++ b/tests/baselines/reference/circularOptionalityRemoval.types @@ -12,7 +12,7 @@ function fn1(x: number | undefined = x > 0 ? x : 0) { } // Report from user function fn2(x?: string = someCondition ? 'value1' : x) { } ->fn2 : (x?: string | undefined) => void +>fn2 : (x?: string) => void >x : string | undefined >someCondition ? 'value1' : x : string | undefined >someCondition : any diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithClass.types b/tests/baselines/reference/circularTypeAliasForUnionWithClass.types index 4127d1c30de00..6a60d579dc618 100644 --- a/tests/baselines/reference/circularTypeAliasForUnionWithClass.types +++ b/tests/baselines/reference/circularTypeAliasForUnionWithClass.types @@ -3,7 +3,7 @@ var v0: T0; >v0 : T0 type T0 = string | I0; ->T0 : T0 +>T0 : string | I0 class I0 { >I0 : I0 @@ -16,7 +16,7 @@ var v3: T3; >v3 : T3 type T3 = string | I3; ->T3 : T3 +>T3 : string | I3 class I3 { >I3 : I3 @@ -29,7 +29,7 @@ var v4: T4; >v4 : T4 type T4 = string | I4; ->T4 : T4 +>T4 : string | I4 class I4 { >I4 : I4 diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types index fa192f67db485..03a7e966828d4 100644 --- a/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types +++ b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types @@ -3,7 +3,7 @@ var v0: T0; >v0 : T0 type T0 = string | I0; ->T0 : T0 +>T0 : string | I0 interface I0 { x: T0; @@ -14,7 +14,7 @@ var v1: T1; >v1 : T1 type T1 = string | I1; ->T1 : T1 +>T1 : string | I1 interface I1 { (): T1; @@ -24,7 +24,7 @@ var v2: T2; >v2 : T2 type T2 = string | I2; ->T2 : T2 +>T2 : string | I2 interface I2 { new (): T2; @@ -34,7 +34,7 @@ var v3: T3; >v3 : T3 type T3 = string | I3; ->T3 : T3 +>T3 : string | I3 interface I3 { [x: number]: T3; @@ -45,7 +45,7 @@ var v4: T4; >v4 : T4 type T4 = string | I4; ->T4 : T4 +>T4 : string | I4 interface I4 { [x: string]: T4; diff --git a/tests/baselines/reference/circularlyReferentialInterfaceAccessNoCrash.types b/tests/baselines/reference/circularlyReferentialInterfaceAccessNoCrash.types index 37dc9060f0bdd..47ac25fbd4068 100644 --- a/tests/baselines/reference/circularlyReferentialInterfaceAccessNoCrash.types +++ b/tests/baselines/reference/circularlyReferentialInterfaceAccessNoCrash.types @@ -1,6 +1,6 @@ === tests/cases/compiler/circularlyReferentialInterfaceAccessNoCrash.ts === type Mxs = Mx<'list', Mxs['p1']>; ->Mxs : Mxs +>Mxs : Mx interface Mx { p1: T; @@ -11,8 +11,8 @@ interface Mx { } type ArrElem = ['list', ArrElem[number][0]][]; ->ArrElem : ArrElem +>ArrElem : [any, any][] type TupleElem = [['list', TupleElem[0][0]]]; ->TupleElem : TupleElem +>TupleElem : [[any, any]] diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types index c50aef1cf1482..22a44a1608678 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts === type StringTree = string | StringTreeCollection; ->StringTree : StringTree +>StringTree : string | StringTreeCollection class StringTreeCollectionBase { >StringTreeCollectionBase : StringTreeCollectionBase diff --git a/tests/baselines/reference/classPropertyErrorOnNameOnly.types b/tests/baselines/reference/classPropertyErrorOnNameOnly.types index 4dece714b92b3..232ca92cd000b 100644 --- a/tests/baselines/reference/classPropertyErrorOnNameOnly.types +++ b/tests/baselines/reference/classPropertyErrorOnNameOnly.types @@ -1,9 +1,9 @@ === tests/cases/compiler/classPropertyErrorOnNameOnly.ts === type Values = 1 | 2 | 3 | 4 | 5 | 6 ->Values : Values +>Values : 1 | 2 | 3 | 4 | 5 | 6 type FuncType = (arg: Values) => string ->FuncType : FuncType +>FuncType : (arg: Values) => string >arg : Values // turn on strictNullChecks diff --git a/tests/baselines/reference/coAndContraVariantInferences.types b/tests/baselines/reference/coAndContraVariantInferences.types index b8d48b413397f..33ef1c87d4806 100644 --- a/tests/baselines/reference/coAndContraVariantInferences.types +++ b/tests/baselines/reference/coAndContraVariantInferences.types @@ -1,10 +1,10 @@ === tests/cases/compiler/coAndContraVariantInferences.ts === type A = { kind: 'a' }; ->A : A +>A : { kind: 'a'; } >kind : "a" type B = { kind: 'b' }; ->B : B +>B : { kind: 'b'; } >kind : "b" declare const a: A; diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types index ae32097c462c3..4ebbecbc555e8 100644 --- a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types @@ -1,6 +1,6 @@ === tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts === type BrandedNum = number & { __numberBrand: any }; ->BrandedNum : BrandedNum +>BrandedNum : number & { __numberBrand: any; } >__numberBrand : any var x : BrandedNum; diff --git a/tests/baselines/reference/completionEntryForUnionMethod.baseline b/tests/baselines/reference/completionEntryForUnionMethod.baseline index f03ee666dc0d8..b46b77f0f7641 100644 --- a/tests/baselines/reference/completionEntryForUnionMethod.baseline +++ b/tests/baselines/reference/completionEntryForUnionMethod.baseline @@ -6,6 +6,7 @@ "name": "" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, diff --git a/tests/baselines/reference/completionImportCallAssertion.baseline b/tests/baselines/reference/completionImportCallAssertion.baseline index 6009fb9e67f87..2e54c403997e0 100644 --- a/tests/baselines/reference/completionImportCallAssertion.baseline +++ b/tests/baselines/reference/completionImportCallAssertion.baseline @@ -6,6 +6,7 @@ "name": "0" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -73,6 +74,7 @@ "name": "1" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, diff --git a/tests/baselines/reference/completionsCommentsClass.baseline b/tests/baselines/reference/completionsCommentsClass.baseline index 66766ee70bef1..5dce64b756ea7 100644 --- a/tests/baselines/reference/completionsCommentsClass.baseline +++ b/tests/baselines/reference/completionsCommentsClass.baseline @@ -6,6 +6,7 @@ "name": "26" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -1339,7 +1340,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -1452,7 +1453,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsClassMembers.baseline b/tests/baselines/reference/completionsCommentsClassMembers.baseline index af89101b92aed..6180976aabaa7 100644 --- a/tests/baselines/reference/completionsCommentsClassMembers.baseline +++ b/tests/baselines/reference/completionsCommentsClassMembers.baseline @@ -6,6 +6,7 @@ "name": "4" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -754,6 +755,7 @@ "name": "5" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -2367,7 +2369,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -2480,7 +2482,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -4818,6 +4820,7 @@ "name": "7" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -5566,6 +5569,7 @@ "name": "9" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -6314,6 +6318,7 @@ "name": "11" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -7062,6 +7067,7 @@ "name": "12" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -7810,6 +7816,7 @@ "name": "13" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -9423,7 +9430,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -9536,7 +9543,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -11874,6 +11881,7 @@ "name": "16" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -12622,6 +12630,7 @@ "name": "17" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -14235,7 +14244,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -14348,7 +14357,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -16686,6 +16695,7 @@ "name": "19" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -17434,6 +17444,7 @@ "name": "21" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -18182,6 +18193,7 @@ "name": "23" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -18930,6 +18942,7 @@ "name": "24" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -19678,6 +19691,7 @@ "name": "25" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -21291,7 +21305,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -21404,7 +21418,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -23742,6 +23756,7 @@ "name": "29" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -25355,7 +25370,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -25468,7 +25483,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -27806,6 +27821,7 @@ "name": "30" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -28961,6 +28977,7 @@ "name": "31" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -30574,7 +30591,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -30687,7 +30704,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -33025,6 +33042,7 @@ "name": "33" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -34592,7 +34610,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -34705,7 +34723,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -37043,6 +37061,7 @@ "name": "34" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -38198,6 +38217,7 @@ "name": "35" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -39765,7 +39785,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -39878,7 +39898,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -42216,6 +42236,7 @@ "name": "36" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -43371,6 +43392,7 @@ "name": "38" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -44984,7 +45006,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -45097,7 +45119,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -47435,6 +47457,7 @@ "name": "39" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -48590,6 +48613,7 @@ "name": "40" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -50203,7 +50227,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -50316,7 +50340,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -52654,6 +52678,7 @@ "name": "41" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -53809,6 +53834,7 @@ "name": "42" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -55422,7 +55448,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -55535,7 +55561,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -57873,6 +57899,7 @@ "name": "45" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -59481,7 +59508,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -59594,7 +59621,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -61932,6 +61959,7 @@ "name": "49" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -63540,7 +63568,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -63653,7 +63681,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -65991,6 +66019,7 @@ "name": "52" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -67599,7 +67628,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -67712,7 +67741,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -70050,6 +70079,7 @@ "name": "56" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -71658,7 +71688,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -71771,7 +71801,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -74109,6 +74139,7 @@ "name": "59" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -75717,7 +75748,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -75830,7 +75861,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -78168,6 +78199,7 @@ "name": "63" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -79776,7 +79808,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -79889,7 +79921,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -82227,6 +82259,7 @@ "name": "67" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -82610,6 +82643,7 @@ "name": "87" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -84175,7 +84209,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -84288,7 +84322,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -86782,6 +86816,7 @@ "name": "88" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -87937,6 +87972,7 @@ "name": "109" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -89531,7 +89567,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -89644,7 +89680,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -92138,6 +92174,7 @@ "name": "110" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -92362,6 +92399,7 @@ "name": "114" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, @@ -92461,6 +92499,7 @@ "name": "115" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -94142,7 +94181,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -94255,7 +94294,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsCommentParsing.baseline b/tests/baselines/reference/completionsCommentsCommentParsing.baseline index 1ec7d5e207235..d4a9a88a0a196 100644 --- a/tests/baselines/reference/completionsCommentsCommentParsing.baseline +++ b/tests/baselines/reference/completionsCommentsCommentParsing.baseline @@ -6,6 +6,7 @@ "name": "18" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -3202,7 +3203,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -3315,7 +3316,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -5653,6 +5654,7 @@ "name": "15" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -8850,7 +8852,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -8963,7 +8965,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -12096,6 +12098,7 @@ "name": "24" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -15268,7 +15271,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -15381,7 +15384,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -17719,6 +17722,7 @@ "name": "27" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -20812,7 +20816,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -20925,7 +20929,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -23419,6 +23423,7 @@ "name": "39" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -26710,7 +26715,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -26823,7 +26828,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -29161,6 +29166,7 @@ "name": "44" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -32358,7 +32364,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -32471,7 +32477,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -35604,6 +35610,7 @@ "name": "" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -38697,7 +38704,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -38810,7 +38817,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline index ae41c9cc50c9e..3c056e5f26396 100644 --- a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline @@ -6,6 +6,7 @@ "name": "3" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -1070,7 +1071,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -1183,7 +1184,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -4316,6 +4317,7 @@ "name": "7" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": true, @@ -5341,7 +5343,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -5454,7 +5456,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -7792,6 +7794,7 @@ "name": "9" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -8856,7 +8859,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -8969,7 +8972,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline index 9c1bc3392836e..e153a2ecdaf3c 100644 --- a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline @@ -6,6 +6,7 @@ "name": "2" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -1246,7 +1247,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -1359,7 +1360,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -3853,6 +3854,7 @@ "name": "4" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -5173,7 +5175,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -5286,7 +5288,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -8575,6 +8577,7 @@ "name": "15" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -9790,7 +9793,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -9903,7 +9906,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -12241,6 +12244,7 @@ "name": "17" }, "completionList": { + "flags": 0, "isGlobalCompletion": true, "isMemberCompletion": false, "isNewIdentifierLocation": false, @@ -13489,7 +13493,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -13602,7 +13606,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsJSDocTags.baseline b/tests/baselines/reference/completionsJSDocTags.baseline index 4c876248179c9..945b84dd88ba7 100644 --- a/tests/baselines/reference/completionsJSDocTags.baseline +++ b/tests/baselines/reference/completionsJSDocTags.baseline @@ -6,6 +6,7 @@ "name": "14" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, diff --git a/tests/baselines/reference/completionsSalsaMethodsOnAssignedFunctionExpressions.baseline b/tests/baselines/reference/completionsSalsaMethodsOnAssignedFunctionExpressions.baseline index 4c5bcf2c68d03..732ce4a31642a 100644 --- a/tests/baselines/reference/completionsSalsaMethodsOnAssignedFunctionExpressions.baseline +++ b/tests/baselines/reference/completionsSalsaMethodsOnAssignedFunctionExpressions.baseline @@ -6,6 +6,7 @@ "name": "2" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 327daf9f0d9a2..0d3fe39d755c9 100644 --- a/tests/baselines/reference/completionsStringMethods.baseline +++ b/tests/baselines/reference/completionsStringMethods.baseline @@ -6,6 +6,7 @@ "name": "1" }, "completionList": { + "flags": 0, "isGlobalCompletion": false, "isMemberCompletion": true, "isNewIdentifierLocation": false, diff --git a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.types b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.types index 0132151408814..a499495da42c2 100644 --- a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.types +++ b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.types @@ -22,7 +22,7 @@ interface EmailChannel { } type Channel = TextChannel | EmailChannel; ->Channel : Channel +>Channel : TextChannel | EmailChannel export type ChannelType = Channel extends { type: infer R } ? R : never; >ChannelType : "text" | "email" diff --git a/tests/baselines/reference/computedPropertyName.types b/tests/baselines/reference/computedPropertyName.types index caab943f248ec..98722138b8c32 100644 --- a/tests/baselines/reference/computedPropertyName.types +++ b/tests/baselines/reference/computedPropertyName.types @@ -16,7 +16,7 @@ interface Component { } type T = { ->T : T +>T : { [onInit]: any; } [onInit]: any; >[onInit] : any diff --git a/tests/baselines/reference/computedTypesKeyofNoIndexSignatureType.types b/tests/baselines/reference/computedTypesKeyofNoIndexSignatureType.types index 6adec9195f253..ecf52ba235433 100644 --- a/tests/baselines/reference/computedTypesKeyofNoIndexSignatureType.types +++ b/tests/baselines/reference/computedTypesKeyofNoIndexSignatureType.types @@ -18,11 +18,11 @@ type OmitIndex = { }; type IndexObject = { [key: string]: unknown; }; ->IndexObject : IndexObject +>IndexObject : { [key: string]: unknown; } >key : string type FooBar = { foo: "hello"; bar: "world"; }; ->FooBar : FooBar +>FooBar : { foo: "hello"; bar: "world"; } >foo : "hello" >bar : "world" diff --git a/tests/baselines/reference/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.types b/tests/baselines/reference/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.types index a4709500c7789..50391d7c0dc3d 100644 --- a/tests/baselines/reference/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.types +++ b/tests/baselines/reference/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.types @@ -1,6 +1,6 @@ === tests/cases/compiler/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.ts === type BigUnion = ->BigUnion : BigUnion +>BigUnion : { name: '0'; children: BigUnion[]; } | { name: '1'; children: BigUnion[]; } | { name: '2'; children: BigUnion[]; } | { name: '3'; children: BigUnion[]; } | { name: '4'; children: BigUnion[]; } | { name: '5'; children: BigUnion[]; } | { name: '6'; children: BigUnion[]; } | { name: '7'; children: BigUnion[]; } | { name: '8'; children: BigUnion[]; } | { name: '9'; children: BigUnion[]; } | { name: '10'; children: BigUnion[]; } | { name: '11'; children: BigUnion[]; } | { name: '12'; children: BigUnion[]; } | { name: '13'; children: BigUnion[]; } | { name: '14'; children: BigUnion[]; } | { name: '15'; children: BigUnion[]; } | { name: '16'; children: BigUnion[]; } | { name: '17'; children: BigUnion[]; } | { name: '18'; children: BigUnion[]; } | { name: '19'; children: BigUnion[]; } | { name: '20'; children: BigUnion[]; } | { name: '21'; children: BigUnion[]; } | { name: '22'; children: BigUnion[]; } | { name: '23'; children: BigUnion[]; } | { name: '24'; children: BigUnion[]; } | { name: '25'; children: BigUnion[]; } | { name: '26'; children: BigUnion[]; } | { name: '27'; children: BigUnion[]; } | { name: '28'; children: BigUnion[]; } | { name: '29'; children: BigUnion[]; } | { name: '30'; children: BigUnion[]; } | { name: '31'; children: BigUnion[]; } | { name: '32'; children: BigUnion[]; } | { name: '33'; children: BigUnion[]; } | { name: '34'; children: BigUnion[]; } | { name: '35'; children: BigUnion[]; } | { name: '36'; children: BigUnion[]; } | { name: '37'; children: BigUnion[]; } | { name: '38'; children: BigUnion[]; } | { name: '39'; children: BigUnion[]; } | { name: '40'; children: BigUnion[]; } | { name: '41'; children: BigUnion[]; } | { name: '42'; children: BigUnion[]; } | { name: '43'; children: BigUnion[]; } | { name: '44'; children: BigUnion[]; } | { name: '45'; children: BigUnion[]; } | { name: '46'; children: BigUnion[]; } | { name: '47'; children: BigUnion[]; } | { name: '48'; children: BigUnion[]; } | { name: '49'; children: BigUnion[]; } | { name: '50'; children: BigUnion[]; } | { name: '51'; children: BigUnion[]; } | { name: '52'; children: BigUnion[]; } | { name: '53'; children: BigUnion[]; } | { name: '54'; children: BigUnion[]; } | { name: '55'; children: BigUnion[]; } | { name: '56'; children: BigUnion[]; } | { name: '57'; children: BigUnion[]; } | { name: '58'; children: BigUnion[]; } | { name: '59'; children: BigUnion[]; } | { name: '60'; children: BigUnion[]; } | { name: '61'; children: BigUnion[]; } | { name: '62'; children: BigUnion[]; } | { name: '63'; children: BigUnion[]; } | { name: '64'; children: BigUnion[]; } | { name: '65'; children: BigUnion[]; } | { name: '66'; children: BigUnion[]; } | { name: '67'; children: BigUnion[]; } | { name: '68'; children: BigUnion[]; } | { name: '69'; children: BigUnion[]; } | { name: '70'; children: BigUnion[]; } | { name: '71'; children: BigUnion[]; } | { name: '72'; children: BigUnion[]; } | { name: '73'; children: BigUnion[]; } | { name: '74'; children: BigUnion[]; } | { name: '75'; children: BigUnion[]; } | { name: '76'; children: BigUnion[]; } | { name: '77'; children: BigUnion[]; } | { name: '78'; children: BigUnion[]; } | { name: '79'; children: BigUnion[]; } | { name: '80'; children: BigUnion[]; } | { name: '81'; children: BigUnion[]; } | { name: '82'; children: BigUnion[]; } | { name: '83'; children: BigUnion[]; } | { name: '84'; children: BigUnion[]; } | { name: '85'; children: BigUnion[]; } | { name: '86'; children: BigUnion[]; } | { name: '87'; children: BigUnion[]; } | { name: '88'; children: BigUnion[]; } | { name: '89'; children: BigUnion[]; } | { name: '90'; children: BigUnion[]; } | { name: '91'; children: BigUnion[]; } | { name: '92'; children: BigUnion[]; } | { name: '93'; children: BigUnion[]; } | { name: '94'; children: BigUnion[]; } | { name: '95'; children: BigUnion[]; } | { name: '96'; children: BigUnion[]; } | { name: '97'; children: BigUnion[]; } | { name: '98'; children: BigUnion[]; } | { name: '99'; children: BigUnion[]; } | { name: '100'; children: BigUnion[]; } | { name: '101'; children: BigUnion[]; } | { name: '102'; children: BigUnion[]; } | { name: '103'; children: BigUnion[]; } | { name: '104'; children: BigUnion[]; } | { name: '105'; children: BigUnion[]; } | { name: '106'; children: BigUnion[]; } | { name: '107'; children: BigUnion[]; } | { name: '108'; children: BigUnion[]; } | { name: '109'; children: BigUnion[]; } | { name: '110'; children: BigUnion[]; } | { name: '111'; children: BigUnion[]; } | { name: '112'; children: BigUnion[]; } | { name: '113'; children: BigUnion[]; } | { name: '114'; children: BigUnion[]; } | { name: '115'; children: BigUnion[]; } | { name: '116'; children: BigUnion[]; } | { name: '117'; children: BigUnion[]; } | { name: '118'; children: BigUnion[]; } | { name: '119'; children: BigUnion[]; } | { name: '120'; children: BigUnion[]; } | { name: '121'; children: BigUnion[]; } | { name: '122'; children: BigUnion[]; } | { name: '123'; children: BigUnion[]; } | { name: '124'; children: BigUnion[]; } | { name: '125'; children: BigUnion[]; } | { name: '126'; children: BigUnion[]; } | { name: '127'; children: BigUnion[]; } | { name: '128'; children: BigUnion[]; } | { name: '129'; children: BigUnion[]; } | { name: '130'; children: BigUnion[]; } | { name: '131'; children: BigUnion[]; } | { name: '132'; children: BigUnion[]; } | { name: '133'; children: BigUnion[]; } | { name: '134'; children: BigUnion[]; } | { name: '135'; children: BigUnion[]; } | { name: '136'; children: BigUnion[]; } | { name: '137'; children: BigUnion[]; } | { name: '138'; children: BigUnion[]; } | { name: '139'; children: BigUnion[]; } | { name: '140'; children: BigUnion[]; } | { name: '141'; children: BigUnion[]; } | { name: '142'; children: BigUnion[]; } | { name: '143'; children: BigUnion[]; } | { name: '144'; children: BigUnion[]; } | { name: '145'; children: BigUnion[]; } | { name: '146'; children: BigUnion[]; } | { name: '147'; children: BigUnion[]; } | { name: '148'; children: BigUnion[]; } | { name: '149'; children: BigUnion[]; } | { name: '150'; children: BigUnion[]; } | { name: '151'; children: BigUnion[]; } | { name: '152'; children: BigUnion[]; } | { name: '153'; children: BigUnion[]; } | { name: '154'; children: BigUnion[]; } | { name: '155'; children: BigUnion[]; } | { name: '156'; children: BigUnion[]; } | { name: '157'; children: BigUnion[]; } | { name: '158'; children: BigUnion[]; } | { name: '159'; children: BigUnion[]; } | { name: '160'; children: BigUnion[]; } | { name: '161'; children: BigUnion[]; } | { name: '162'; children: BigUnion[]; } | { name: '163'; children: BigUnion[]; } | { name: '164'; children: BigUnion[]; } | { name: '165'; children: BigUnion[]; } | { name: '166'; children: BigUnion[]; } | { name: '167'; children: BigUnion[]; } | { name: '168'; children: BigUnion[]; } | { name: '169'; children: BigUnion[]; } | { name: '170'; children: BigUnion[]; } | { name: '171'; children: BigUnion[]; } | { name: '172'; children: BigUnion[]; } | { name: '173'; children: BigUnion[]; } | { name: '174'; children: BigUnion[]; } | { name: '175'; children: BigUnion[]; } | { name: '176'; children: BigUnion[]; } | { name: '177'; children: BigUnion[]; } | { name: '178'; children: BigUnion[]; } | { name: '179'; children: BigUnion[]; } | { name: '180'; children: BigUnion[]; } | { name: '181'; children: BigUnion[]; } | { name: '182'; children: BigUnion[]; } | { name: '183'; children: BigUnion[]; } | { name: '184'; children: BigUnion[]; } | { name: '185'; children: BigUnion[]; } | { name: '186'; children: BigUnion[]; } | { name: '187'; children: BigUnion[]; } | { name: '188'; children: BigUnion[]; } | { name: '189'; children: BigUnion[]; } | { name: '190'; children: BigUnion[]; } | { name: '191'; children: BigUnion[]; } | { name: '192'; children: BigUnion[]; } | { name: '193'; children: BigUnion[]; } | { name: '194'; children: BigUnion[]; } | { name: '195'; children: BigUnion[]; } | { name: '196'; children: BigUnion[]; } | { name: '197'; children: BigUnion[]; } | { name: '198'; children: BigUnion[]; } | { name: '199'; children: BigUnion[]; } | { name: '200'; children: BigUnion[]; } | { name: '201'; children: BigUnion[]; } | { name: '202'; children: BigUnion[]; } | { name: '203'; children: BigUnion[]; } | { name: '204'; children: BigUnion[]; } | { name: '205'; children: BigUnion[]; } | { name: '206'; children: BigUnion[]; } | { name: '207'; children: BigUnion[]; } | { name: '208'; children: BigUnion[]; } | { name: '209'; children: BigUnion[]; } | { name: '210'; children: BigUnion[]; } | { name: '211'; children: BigUnion[]; } | { name: '212'; children: BigUnion[]; } | { name: '213'; children: BigUnion[]; } | { name: '214'; children: BigUnion[]; } | { name: '215'; children: BigUnion[]; } | { name: '216'; children: BigUnion[]; } | { name: '217'; children: BigUnion[]; } | { name: '218'; children: BigUnion[]; } | { name: '219'; children: BigUnion[]; } | { name: '220'; children: BigUnion[]; } | { name: '221'; children: BigUnion[]; } | { name: '222'; children: BigUnion[]; } | { name: '223'; children: BigUnion[]; } | { name: '224'; children: BigUnion[]; } | { name: '225'; children: BigUnion[]; } | { name: '226'; children: BigUnion[]; } | { name: '227'; children: BigUnion[]; } | { name: '228'; children: BigUnion[]; } | { name: '229'; children: BigUnion[]; } | { name: '230'; children: BigUnion[]; } | { name: '231'; children: BigUnion[]; } | { name: '232'; children: BigUnion[]; } | { name: '233'; children: BigUnion[]; } | { name: '234'; children: BigUnion[]; } | { name: '235'; children: BigUnion[]; } | { name: '236'; children: BigUnion[]; } | { name: '237'; children: BigUnion[]; } | { name: '238'; children: BigUnion[]; } | { name: '239'; children: BigUnion[]; } | { name: '240'; children: BigUnion[]; } | { name: '241'; children: BigUnion[]; } | { name: '242'; children: BigUnion[]; } | { name: '243'; children: BigUnion[]; } | { name: '244'; children: BigUnion[]; } | { name: '245'; children: BigUnion[]; } | { name: '246'; children: BigUnion[]; } | { name: '247'; children: BigUnion[]; } | { name: '248'; children: BigUnion[]; } | { name: '249'; children: BigUnion[]; } | { name: '250'; children: BigUnion[]; } | { name: '251'; children: BigUnion[]; } | { name: '252'; children: BigUnion[]; } | { name: '253'; children: BigUnion[]; } | { name: '254'; children: BigUnion[]; } | { name: '255'; children: BigUnion[]; } | { name: '256'; children: BigUnion[]; } | { name: '257'; children: BigUnion[]; } | { name: '258'; children: BigUnion[]; } | { name: '259'; children: BigUnion[]; } | { name: '260'; children: BigUnion[]; } | { name: '261'; children: BigUnion[]; } | { name: '262'; children: BigUnion[]; } | { name: '263'; children: BigUnion[]; } | { name: '264'; children: BigUnion[]; } | { name: '265'; children: BigUnion[]; } | { name: '266'; children: BigUnion[]; } | { name: '267'; children: BigUnion[]; } | { name: '268'; children: BigUnion[]; } | { name: '269'; children: BigUnion[]; } | { name: '270'; children: BigUnion[]; } | { name: '271'; children: BigUnion[]; } | { name: '272'; children: BigUnion[]; } | { name: '273'; children: BigUnion[]; } | { name: '274'; children: BigUnion[]; } | { name: '275'; children: BigUnion[]; } | { name: '276'; children: BigUnion[]; } | { name: '277'; children: BigUnion[]; } | { name: '278'; children: BigUnion[]; } | { name: '279'; children: BigUnion[]; } | { name: '280'; children: BigUnion[]; } | { name: '281'; children: BigUnion[]; } | { name: '282'; children: BigUnion[]; } | { name: '283'; children: BigUnion[]; } | { name: '284'; children: BigUnion[]; } | { name: '285'; children: BigUnion[]; } | { name: '286'; children: BigUnion[]; } | { name: '287'; children: BigUnion[]; } | { name: '288'; children: BigUnion[]; } | { name: '289'; children: BigUnion[]; } | { name: '290'; children: BigUnion[]; } | { name: '291'; children: BigUnion[]; } | { name: '292'; children: BigUnion[]; } | { name: '293'; children: BigUnion[]; } | { name: '294'; children: BigUnion[]; } | { name: '295'; children: BigUnion[]; } | { name: '296'; children: BigUnion[]; } | { name: '297'; children: BigUnion[]; } | { name: '298'; children: BigUnion[]; } | { name: '299'; children: BigUnion[]; } | { name: '300'; children: BigUnion[]; } | { name: '301'; children: BigUnion[]; } | { name: '302'; children: BigUnion[]; } | { name: '303'; children: BigUnion[]; } | { name: '304'; children: BigUnion[]; } | { name: '305'; children: BigUnion[]; } | { name: '306'; children: BigUnion[]; } | { name: '307'; children: BigUnion[]; } | { name: '308'; children: BigUnion[]; } | { name: '309'; children: BigUnion[]; } | { name: '310'; children: BigUnion[]; } | { name: '311'; children: BigUnion[]; } | { name: '312'; children: BigUnion[]; } | { name: '313'; children: BigUnion[]; } | { name: '314'; children: BigUnion[]; } | { name: '315'; children: BigUnion[]; } | { name: '316'; children: BigUnion[]; } | { name: '317'; children: BigUnion[]; } | { name: '318'; children: BigUnion[]; } | { name: '319'; children: BigUnion[]; } | { name: '320'; children: BigUnion[]; } | { name: '321'; children: BigUnion[]; } | { name: '322'; children: BigUnion[]; } | { name: '323'; children: BigUnion[]; } | { name: '324'; children: BigUnion[]; } | { name: '325'; children: BigUnion[]; } | { name: '326'; children: BigUnion[]; } | { name: '327'; children: BigUnion[]; } | { name: '328'; children: BigUnion[]; } | { name: '329'; children: BigUnion[]; } | { name: '330'; children: BigUnion[]; } | { name: '331'; children: BigUnion[]; } | { name: '332'; children: BigUnion[]; } | { name: '333'; children: BigUnion[]; } | { name: '334'; children: BigUnion[]; } | { name: '335'; children: BigUnion[]; } | { name: '336'; children: BigUnion[]; } | { name: '337'; children: BigUnion[]; } | { name: '338'; children: BigUnion[]; } | { name: '339'; children: BigUnion[]; } | { name: '340'; children: BigUnion[]; } | { name: '341'; children: BigUnion[]; } | { name: '342'; children: BigUnion[]; } | { name: '343'; children: BigUnion[]; } | { name: '344'; children: BigUnion[]; } | { name: '345'; children: BigUnion[]; } | { name: '346'; children: BigUnion[]; } | { name: '347'; children: BigUnion[]; } | { name: '348'; children: BigUnion[]; } | { name: '349'; children: BigUnion[]; } | { name: '350'; children: BigUnion[]; } | { name: '351'; children: BigUnion[]; } | { name: '352'; children: BigUnion[]; } | { name: '353'; children: BigUnion[]; } | { name: '354'; children: BigUnion[]; } | { name: '355'; children: BigUnion[]; } | { name: '356'; children: BigUnion[]; } | { name: '357'; children: BigUnion[]; } | { name: '358'; children: BigUnion[]; } | { name: '359'; children: BigUnion[]; } | { name: '360'; children: BigUnion[]; } | { name: '361'; children: BigUnion[]; } | { name: '362'; children: BigUnion[]; } | { name: '363'; children: BigUnion[]; } | { name: '364'; children: BigUnion[]; } | { name: '365'; children: BigUnion[]; } | { name: '366'; children: BigUnion[]; } | { name: '367'; children: BigUnion[]; } | { name: '368'; children: BigUnion[]; } | { name: '369'; children: BigUnion[]; } | { name: '370'; children: BigUnion[]; } | { name: '371'; children: BigUnion[]; } | { name: '372'; children: BigUnion[]; } | { name: '373'; children: BigUnion[]; } | { name: '374'; children: BigUnion[]; } | { name: '375'; children: BigUnion[]; } | { name: '376'; children: BigUnion[]; } | { name: '377'; children: BigUnion[]; } | { name: '378'; children: BigUnion[]; } | { name: '379'; children: BigUnion[]; } | { name: '380'; children: BigUnion[]; } | { name: '381'; children: BigUnion[]; } | { name: '382'; children: BigUnion[]; } | { name: '383'; children: BigUnion[]; } | { name: '384'; children: BigUnion[]; } | { name: '385'; children: BigUnion[]; } | { name: '386'; children: BigUnion[]; } | { name: '387'; children: BigUnion[]; } | { name: '388'; children: BigUnion[]; } | { name: '389'; children: BigUnion[]; } | { name: '390'; children: BigUnion[]; } | { name: '391'; children: BigUnion[]; } | { name: '392'; children: BigUnion[]; } | { name: '393'; children: BigUnion[]; } | { name: '394'; children: BigUnion[]; } | { name: '395'; children: BigUnion[]; } | { name: '396'; children: BigUnion[]; } | { name: '397'; children: BigUnion[]; } | { name: '398'; children: BigUnion[]; } | { name: '399'; children: BigUnion[]; } | { name: '400'; children: BigUnion[]; } | { name: '401'; children: BigUnion[]; } | { name: '402'; children: BigUnion[]; } | { name: '403'; children: BigUnion[]; } | { name: '404'; children: BigUnion[]; } | { name: '405'; children: BigUnion[]; } | { name: '406'; children: BigUnion[]; } | { name: '407'; children: BigUnion[]; } | { name: '408'; children: BigUnion[]; } | { name: '409'; children: BigUnion[]; } | { name: '410'; children: BigUnion[]; } | { name: '411'; children: BigUnion[]; } | { name: '412'; children: BigUnion[]; } | { name: '413'; children: BigUnion[]; } | { name: '414'; children: BigUnion[]; } | { name: '415'; children: BigUnion[]; } | { name: '416'; children: BigUnion[]; } | { name: '417'; children: BigUnion[]; } | { name: '418'; children: BigUnion[]; } | { name: '419'; children: BigUnion[]; } | { name: '420'; children: BigUnion[]; } | { name: '421'; children: BigUnion[]; } | { name: '422'; children: BigUnion[]; } | { name: '423'; children: BigUnion[]; } | { name: '424'; children: BigUnion[]; } | { name: '425'; children: BigUnion[]; } | { name: '426'; children: BigUnion[]; } | { name: '427'; children: BigUnion[]; } | { name: '428'; children: BigUnion[]; } | { name: '429'; children: BigUnion[]; } | { name: '430'; children: BigUnion[]; } | { name: '431'; children: BigUnion[]; } | { name: '432'; children: BigUnion[]; } | { name: '433'; children: BigUnion[]; } | { name: '434'; children: BigUnion[]; } | { name: '435'; children: BigUnion[]; } | { name: '436'; children: BigUnion[]; } | { name: '437'; children: BigUnion[]; } | { name: '438'; children: BigUnion[]; } | { name: '439'; children: BigUnion[]; } | { name: '440'; children: BigUnion[]; } | { name: '441'; children: BigUnion[]; } | { name: '442'; children: BigUnion[]; } | { name: '443'; children: BigUnion[]; } | { name: '444'; children: BigUnion[]; } | { name: '445'; children: BigUnion[]; } | { name: '446'; children: BigUnion[]; } | { name: '447'; children: BigUnion[]; } | { name: '448'; children: BigUnion[]; } | { name: '449'; children: BigUnion[]; } | { name: '450'; children: BigUnion[]; } | { name: '451'; children: BigUnion[]; } | { name: '452'; children: BigUnion[]; } | { name: '453'; children: BigUnion[]; } | { name: '454'; children: BigUnion[]; } | { name: '455'; children: BigUnion[]; } | { name: '456'; children: BigUnion[]; } | { name: '457'; children: BigUnion[]; } | { name: '458'; children: BigUnion[]; } | { name: '459'; children: BigUnion[]; } | { name: '460'; children: BigUnion[]; } | { name: '461'; children: BigUnion[]; } | { name: '462'; children: BigUnion[]; } | { name: '463'; children: BigUnion[]; } | { name: '464'; children: BigUnion[]; } | { name: '465'; children: BigUnion[]; } | { name: '466'; children: BigUnion[]; } | { name: '467'; children: BigUnion[]; } | { name: '468'; children: BigUnion[]; } | { name: '469'; children: BigUnion[]; } | { name: '470'; children: BigUnion[]; } | { name: '471'; children: BigUnion[]; } | { name: '472'; children: BigUnion[]; } | { name: '473'; children: BigUnion[]; } | { name: '474'; children: BigUnion[]; } | { name: '475'; children: BigUnion[]; } | { name: '476'; children: BigUnion[]; } | { name: '477'; children: BigUnion[]; } | { name: '478'; children: BigUnion[]; } | { name: '479'; children: BigUnion[]; } | { name: '480'; children: BigUnion[]; } | { name: '481'; children: BigUnion[]; } | { name: '482'; children: BigUnion[]; } | { name: '483'; children: BigUnion[]; } | { name: '484'; children: BigUnion[]; } | { name: '485'; children: BigUnion[]; } | { name: '486'; children: BigUnion[]; } | { name: '487'; children: BigUnion[]; } | { name: '488'; children: BigUnion[]; } | { name: '489'; children: BigUnion[]; } | { name: '490'; children: BigUnion[]; } | { name: '491'; children: BigUnion[]; } | { name: '492'; children: BigUnion[]; } | { name: '493'; children: BigUnion[]; } | { name: '494'; children: BigUnion[]; } | { name: '495'; children: BigUnion[]; } | { name: '496'; children: BigUnion[]; } | { name: '497'; children: BigUnion[]; } | { name: '498'; children: BigUnion[]; } | { name: '499'; children: BigUnion[]; } | { name: '500'; children: BigUnion[]; } | { name: '501'; children: BigUnion[]; } | { name: '502'; children: BigUnion[]; } | { name: '503'; children: BigUnion[]; } | { name: '504'; children: BigUnion[]; } | { name: '505'; children: BigUnion[]; } | { name: '506'; children: BigUnion[]; } | { name: '507'; children: BigUnion[]; } | { name: '508'; children: BigUnion[]; } | { name: '509'; children: BigUnion[]; } | { name: '510'; children: BigUnion[]; } | { name: '511'; children: BigUnion[]; } | { name: '512'; children: BigUnion[]; } | { name: '513'; children: BigUnion[]; } | { name: '514'; children: BigUnion[]; } | { name: '515'; children: BigUnion[]; } | { name: '516'; children: BigUnion[]; } | { name: '517'; children: BigUnion[]; } | { name: '518'; children: BigUnion[]; } | { name: '519'; children: BigUnion[]; } | { name: '520'; children: BigUnion[]; } | { name: '521'; children: BigUnion[]; } | { name: '522'; children: BigUnion[]; } | { name: '523'; children: BigUnion[]; } | { name: '524'; children: BigUnion[]; } | { name: '525'; children: BigUnion[]; } | { name: '526'; children: BigUnion[]; } | { name: '527'; children: BigUnion[]; } | { name: '528'; children: BigUnion[]; } | { name: '529'; children: BigUnion[]; } | { name: '530'; children: BigUnion[]; } | { name: '531'; children: BigUnion[]; } | { name: '532'; children: BigUnion[]; } | { name: '533'; children: BigUnion[]; } | { name: '534'; children: BigUnion[]; } | { name: '535'; children: BigUnion[]; } | { name: '536'; children: BigUnion[]; } | { name: '537'; children: BigUnion[]; } | { name: '538'; children: BigUnion[]; } | { name: '539'; children: BigUnion[]; } | { name: '540'; children: BigUnion[]; } | { name: '541'; children: BigUnion[]; } | { name: '542'; children: BigUnion[]; } | { name: '543'; children: BigUnion[]; } | { name: '544'; children: BigUnion[]; } | { name: '545'; children: BigUnion[]; } | { name: '546'; children: BigUnion[]; } | { name: '547'; children: BigUnion[]; } | { name: '548'; children: BigUnion[]; } | { name: '549'; children: BigUnion[]; } | { name: '550'; children: BigUnion[]; } | { name: '551'; children: BigUnion[]; } | { name: '552'; children: BigUnion[]; } | { name: '553'; children: BigUnion[]; } | { name: '554'; children: BigUnion[]; } | { name: '555'; children: BigUnion[]; } | { name: '556'; children: BigUnion[]; } | { name: '557'; children: BigUnion[]; } | { name: '558'; children: BigUnion[]; } | { name: '559'; children: BigUnion[]; } | { name: '560'; children: BigUnion[]; } | { name: '561'; children: BigUnion[]; } | { name: '562'; children: BigUnion[]; } | { name: '563'; children: BigUnion[]; } | { name: '564'; children: BigUnion[]; } | { name: '565'; children: BigUnion[]; } | { name: '566'; children: BigUnion[]; } | { name: '567'; children: BigUnion[]; } | { name: '568'; children: BigUnion[]; } | { name: '569'; children: BigUnion[]; } | { name: '570'; children: BigUnion[]; } | { name: '571'; children: BigUnion[]; } | { name: '572'; children: BigUnion[]; } | { name: '573'; children: BigUnion[]; } | { name: '574'; children: BigUnion[]; } | { name: '575'; children: BigUnion[]; } | { name: '576'; children: BigUnion[]; } | { name: '577'; children: BigUnion[]; } | { name: '578'; children: BigUnion[]; } | { name: '579'; children: BigUnion[]; } | { name: '580'; children: BigUnion[]; } | { name: '581'; children: BigUnion[]; } | { name: '582'; children: BigUnion[]; } | { name: '583'; children: BigUnion[]; } | { name: '584'; children: BigUnion[]; } | { name: '585'; children: BigUnion[]; } | { name: '586'; children: BigUnion[]; } | { name: '587'; children: BigUnion[]; } | { name: '588'; children: BigUnion[]; } | { name: '589'; children: BigUnion[]; } | { name: '590'; children: BigUnion[]; } | { name: '591'; children: BigUnion[]; } | { name: '592'; children: BigUnion[]; } | { name: '593'; children: BigUnion[]; } | { name: '594'; children: BigUnion[]; } | { name: '595'; children: BigUnion[]; } | { name: '596'; children: BigUnion[]; } | { name: '597'; children: BigUnion[]; } | { name: '598'; children: BigUnion[]; } | { name: '599'; children: BigUnion[]; } | { name: '600'; children: BigUnion[]; } | { name: '601'; children: BigUnion[]; } | { name: '602'; children: BigUnion[]; } | { name: '603'; children: BigUnion[]; } | { name: '604'; children: BigUnion[]; } | { name: '605'; children: BigUnion[]; } | { name: '606'; children: BigUnion[]; } | { name: '607'; children: BigUnion[]; } | { name: '608'; children: BigUnion[]; } | { name: '609'; children: BigUnion[]; } | { name: '610'; children: BigUnion[]; } | { name: '611'; children: BigUnion[]; } | { name: '612'; children: BigUnion[]; } | { name: '613'; children: BigUnion[]; } | { name: '614'; children: BigUnion[]; } | { name: '615'; children: BigUnion[]; } | { name: '616'; children: BigUnion[]; } | { name: '617'; children: BigUnion[]; } | { name: '618'; children: BigUnion[]; } | { name: '619'; children: BigUnion[]; } | { name: '620'; children: BigUnion[]; } | { name: '621'; children: BigUnion[]; } | { name: '622'; children: BigUnion[]; } | { name: '623'; children: BigUnion[]; } | { name: '624'; children: BigUnion[]; } | { name: '625'; children: BigUnion[]; } | { name: '626'; children: BigUnion[]; } | { name: '627'; children: BigUnion[]; } | { name: '628'; children: BigUnion[]; } | { name: '629'; children: BigUnion[]; } | { name: '630'; children: BigUnion[]; } | { name: '631'; children: BigUnion[]; } | { name: '632'; children: BigUnion[]; } | { name: '633'; children: BigUnion[]; } | { name: '634'; children: BigUnion[]; } | { name: '635'; children: BigUnion[]; } | { name: '636'; children: BigUnion[]; } | { name: '637'; children: BigUnion[]; } | { name: '638'; children: BigUnion[]; } | { name: '639'; children: BigUnion[]; } | { name: '640'; children: BigUnion[]; } | { name: '641'; children: BigUnion[]; } | { name: '642'; children: BigUnion[]; } | { name: '643'; children: BigUnion[]; } | { name: '644'; children: BigUnion[]; } | { name: '645'; children: BigUnion[]; } | { name: '646'; children: BigUnion[]; } | { name: '647'; children: BigUnion[]; } | { name: '648'; children: BigUnion[]; } | { name: '649'; children: BigUnion[]; } | { name: '650'; children: BigUnion[]; } | { name: '651'; children: BigUnion[]; } | { name: '652'; children: BigUnion[]; } | { name: '653'; children: BigUnion[]; } | { name: '654'; children: BigUnion[]; } | { name: '655'; children: BigUnion[]; } | { name: '656'; children: BigUnion[]; } | { name: '657'; children: BigUnion[]; } | { name: '658'; children: BigUnion[]; } | { name: '659'; children: BigUnion[]; } | { name: '660'; children: BigUnion[]; } | { name: '661'; children: BigUnion[]; } | { name: '662'; children: BigUnion[]; } | { name: '663'; children: BigUnion[]; } | { name: '664'; children: BigUnion[]; } | { name: '665'; children: BigUnion[]; } | { name: '666'; children: BigUnion[]; } | { name: '667'; children: BigUnion[]; } | { name: '668'; children: BigUnion[]; } | { name: '669'; children: BigUnion[]; } | { name: '670'; children: BigUnion[]; } | { name: '671'; children: BigUnion[]; } | { name: '672'; children: BigUnion[]; } | { name: '673'; children: BigUnion[]; } | { name: '674'; children: BigUnion[]; } | { name: '675'; children: BigUnion[]; } | { name: '676'; children: BigUnion[]; } | { name: '677'; children: BigUnion[]; } | { name: '678'; children: BigUnion[]; } | { name: '679'; children: BigUnion[]; } | { name: '680'; children: BigUnion[]; } | { name: '681'; children: BigUnion[]; } | { name: '682'; children: BigUnion[]; } | { name: '683'; children: BigUnion[]; } | { name: '684'; children: BigUnion[]; } | { name: '685'; children: BigUnion[]; } | { name: '686'; children: BigUnion[]; } | { name: '687'; children: BigUnion[]; } | { name: '688'; children: BigUnion[]; } | { name: '689'; children: BigUnion[]; } | { name: '690'; children: BigUnion[]; } | { name: '691'; children: BigUnion[]; } | { name: '692'; children: BigUnion[]; } | { name: '693'; children: BigUnion[]; } | { name: '694'; children: BigUnion[]; } | { name: '695'; children: BigUnion[]; } | { name: '696'; children: BigUnion[]; } | { name: '697'; children: BigUnion[]; } | { name: '698'; children: BigUnion[]; } | { name: '699'; children: BigUnion[]; } | { name: '700'; children: BigUnion[]; } | { name: '701'; children: BigUnion[]; } | { name: '702'; children: BigUnion[]; } | { name: '703'; children: BigUnion[]; } | { name: '704'; children: BigUnion[]; } | { name: '705'; children: BigUnion[]; } | { name: '706'; children: BigUnion[]; } | { name: '707'; children: BigUnion[]; } | { name: '708'; children: BigUnion[]; } | { name: '709'; children: BigUnion[]; } | { name: '710'; children: BigUnion[]; } | { name: '711'; children: BigUnion[]; } | { name: '712'; children: BigUnion[]; } | { name: '713'; children: BigUnion[]; } | { name: '714'; children: BigUnion[]; } | { name: '715'; children: BigUnion[]; } | { name: '716'; children: BigUnion[]; } | { name: '717'; children: BigUnion[]; } | { name: '718'; children: BigUnion[]; } | { name: '719'; children: BigUnion[]; } | { name: '720'; children: BigUnion[]; } | { name: '721'; children: BigUnion[]; } | { name: '722'; children: BigUnion[]; } | { name: '723'; children: BigUnion[]; } | { name: '724'; children: BigUnion[]; } | { name: '725'; children: BigUnion[]; } | { name: '726'; children: BigUnion[]; } | { name: '727'; children: BigUnion[]; } | { name: '728'; children: BigUnion[]; } | { name: '729'; children: BigUnion[]; } | { name: '730'; children: BigUnion[]; } | { name: '731'; children: BigUnion[]; } | { name: '732'; children: BigUnion[]; } | { name: '733'; children: BigUnion[]; } | { name: '734'; children: BigUnion[]; } | { name: '735'; children: BigUnion[]; } | { name: '736'; children: BigUnion[]; } | { name: '737'; children: BigUnion[]; } | { name: '738'; children: BigUnion[]; } | { name: '739'; children: BigUnion[]; } | { name: '740'; children: BigUnion[]; } | { name: '741'; children: BigUnion[]; } | { name: '742'; children: BigUnion[]; } | { name: '743'; children: BigUnion[]; } | { name: '744'; children: BigUnion[]; } | { name: '745'; children: BigUnion[]; } | { name: '746'; children: BigUnion[]; } | { name: '747'; children: BigUnion[]; } | { name: '748'; children: BigUnion[]; } | { name: '749'; children: BigUnion[]; } | { name: '750'; children: BigUnion[]; } | { name: '751'; children: BigUnion[]; } | { name: '752'; children: BigUnion[]; } | { name: '753'; children: BigUnion[]; } | { name: '754'; children: BigUnion[]; } | { name: '755'; children: BigUnion[]; } | { name: '756'; children: BigUnion[]; } | { name: '757'; children: BigUnion[]; } | { name: '758'; children: BigUnion[]; } | { name: '759'; children: BigUnion[]; } | { name: '760'; children: BigUnion[]; } | { name: '761'; children: BigUnion[]; } | { name: '762'; children: BigUnion[]; } | { name: '763'; children: BigUnion[]; } | { name: '764'; children: BigUnion[]; } | { name: '765'; children: BigUnion[]; } | { name: '766'; children: BigUnion[]; } | { name: '767'; children: BigUnion[]; } | { name: '768'; children: BigUnion[]; } | { name: '769'; children: BigUnion[]; } | { name: '770'; children: BigUnion[]; } | { name: '771'; children: BigUnion[]; } | { name: '772'; children: BigUnion[]; } | { name: '773'; children: BigUnion[]; } | { name: '774'; children: BigUnion[]; } | { name: '775'; children: BigUnion[]; } | { name: '776'; children: BigUnion[]; } | { name: '777'; children: BigUnion[]; } | { name: '778'; children: BigUnion[]; } | { name: '779'; children: BigUnion[]; } | { name: '780'; children: BigUnion[]; } | { name: '781'; children: BigUnion[]; } | { name: '782'; children: BigUnion[]; } | { name: '783'; children: BigUnion[]; } | { name: '784'; children: BigUnion[]; } | { name: '785'; children: BigUnion[]; } | { name: '786'; children: BigUnion[]; } | { name: '787'; children: BigUnion[]; } | { name: '788'; children: BigUnion[]; } | { name: '789'; children: BigUnion[]; } | { name: '790'; children: BigUnion[]; } | { name: '791'; children: BigUnion[]; } | { name: '792'; children: BigUnion[]; } | { name: '793'; children: BigUnion[]; } | { name: '794'; children: BigUnion[]; } | { name: '795'; children: BigUnion[]; } | { name: '796'; children: BigUnion[]; } | { name: '797'; children: BigUnion[]; } | { name: '798'; children: BigUnion[]; } | { name: '799'; children: BigUnion[]; } | { name: '800'; children: BigUnion[]; } | { name: '801'; children: BigUnion[]; } | { name: '802'; children: BigUnion[]; } | { name: '803'; children: BigUnion[]; } | { name: '804'; children: BigUnion[]; } | { name: '805'; children: BigUnion[]; } | { name: '806'; children: BigUnion[]; } | { name: '807'; children: BigUnion[]; } | { name: '808'; children: BigUnion[]; } | { name: '809'; children: BigUnion[]; } | { name: '810'; children: BigUnion[]; } | { name: '811'; children: BigUnion[]; } | { name: '812'; children: BigUnion[]; } | { name: '813'; children: BigUnion[]; } | { name: '814'; children: BigUnion[]; } | { name: '815'; children: BigUnion[]; } | { name: '816'; children: BigUnion[]; } | { name: '817'; children: BigUnion[]; } | { name: '818'; children: BigUnion[]; } | { name: '819'; children: BigUnion[]; } | { name: '820'; children: BigUnion[]; } | { name: '821'; children: BigUnion[]; } | { name: '822'; children: BigUnion[]; } | { name: '823'; children: BigUnion[]; } | { name: '824'; children: BigUnion[]; } | { name: '825'; children: BigUnion[]; } | { name: '826'; children: BigUnion[]; } | { name: '827'; children: BigUnion[]; } | { name: '828'; children: BigUnion[]; } | { name: '829'; children: BigUnion[]; } | { name: '830'; children: BigUnion[]; } | { name: '831'; children: BigUnion[]; } | { name: '832'; children: BigUnion[]; } | { name: '833'; children: BigUnion[]; } | { name: '834'; children: BigUnion[]; } | { name: '835'; children: BigUnion[]; } | { name: '836'; children: BigUnion[]; } | { name: '837'; children: BigUnion[]; } | { name: '838'; children: BigUnion[]; } | { name: '839'; children: BigUnion[]; } | { name: '840'; children: BigUnion[]; } | { name: '841'; children: BigUnion[]; } | { name: '842'; children: BigUnion[]; } | { name: '843'; children: BigUnion[]; } | { name: '844'; children: BigUnion[]; } | { name: '845'; children: BigUnion[]; } | { name: '846'; children: BigUnion[]; } | { name: '847'; children: BigUnion[]; } | { name: '848'; children: BigUnion[]; } | { name: '849'; children: BigUnion[]; } | { name: '850'; children: BigUnion[]; } | { name: '851'; children: BigUnion[]; } | { name: '852'; children: BigUnion[]; } | { name: '853'; children: BigUnion[]; } | { name: '854'; children: BigUnion[]; } | { name: '855'; children: BigUnion[]; } | { name: '856'; children: BigUnion[]; } | { name: '857'; children: BigUnion[]; } | { name: '858'; children: BigUnion[]; } | { name: '859'; children: BigUnion[]; } | { name: '860'; children: BigUnion[]; } | { name: '861'; children: BigUnion[]; } | { name: '862'; children: BigUnion[]; } | { name: '863'; children: BigUnion[]; } | { name: '864'; children: BigUnion[]; } | { name: '865'; children: BigUnion[]; } | { name: '866'; children: BigUnion[]; } | { name: '867'; children: BigUnion[]; } | { name: '868'; children: BigUnion[]; } | { name: '869'; children: BigUnion[]; } | { name: '870'; children: BigUnion[]; } | { name: '871'; children: BigUnion[]; } | { name: '872'; children: BigUnion[]; } | { name: '873'; children: BigUnion[]; } | { name: '874'; children: BigUnion[]; } | { name: '875'; children: BigUnion[]; } | { name: '876'; children: BigUnion[]; } | { name: '877'; children: BigUnion[]; } | { name: '878'; children: BigUnion[]; } | { name: '879'; children: BigUnion[]; } | { name: '880'; children: BigUnion[]; } | { name: '881'; children: BigUnion[]; } | { name: '882'; children: BigUnion[]; } | { name: '883'; children: BigUnion[]; } | { name: '884'; children: BigUnion[]; } | { name: '885'; children: BigUnion[]; } | { name: '886'; children: BigUnion[]; } | { name: '887'; children: BigUnion[]; } | { name: '888'; children: BigUnion[]; } | { name: '889'; children: BigUnion[]; } | { name: '890'; children: BigUnion[]; } | { name: '891'; children: BigUnion[]; } | { name: '892'; children: BigUnion[]; } | { name: '893'; children: BigUnion[]; } | { name: '894'; children: BigUnion[]; } | { name: '895'; children: BigUnion[]; } | { name: '896'; children: BigUnion[]; } | { name: '897'; children: BigUnion[]; } | { name: '898'; children: BigUnion[]; } | { name: '899'; children: BigUnion[]; } | { name: '900'; children: BigUnion[]; } | { name: '901'; children: BigUnion[]; } | { name: '902'; children: BigUnion[]; } | { name: '903'; children: BigUnion[]; } | { name: '904'; children: BigUnion[]; } | { name: '905'; children: BigUnion[]; } | { name: '906'; children: BigUnion[]; } | { name: '907'; children: BigUnion[]; } | { name: '908'; children: BigUnion[]; } | { name: '909'; children: BigUnion[]; } | { name: '910'; children: BigUnion[]; } | { name: '911'; children: BigUnion[]; } | { name: '912'; children: BigUnion[]; } | { name: '913'; children: BigUnion[]; } | { name: '914'; children: BigUnion[]; } | { name: '915'; children: BigUnion[]; } | { name: '916'; children: BigUnion[]; } | { name: '917'; children: BigUnion[]; } | { name: '918'; children: BigUnion[]; } | { name: '919'; children: BigUnion[]; } | { name: '920'; children: BigUnion[]; } | { name: '921'; children: BigUnion[]; } | { name: '922'; children: BigUnion[]; } | { name: '923'; children: BigUnion[]; } | { name: '924'; children: BigUnion[]; } | { name: '925'; children: BigUnion[]; } | { name: '926'; children: BigUnion[]; } | { name: '927'; children: BigUnion[]; } | { name: '928'; children: BigUnion[]; } | { name: '929'; children: BigUnion[]; } | { name: '930'; children: BigUnion[]; } | { name: '931'; children: BigUnion[]; } | { name: '932'; children: BigUnion[]; } | { name: '933'; children: BigUnion[]; } | { name: '934'; children: BigUnion[]; } | { name: '935'; children: BigUnion[]; } | { name: '936'; children: BigUnion[]; } | { name: '937'; children: BigUnion[]; } | { name: '938'; children: BigUnion[]; } | { name: '939'; children: BigUnion[]; } | { name: '940'; children: BigUnion[]; } | { name: '941'; children: BigUnion[]; } | { name: '942'; children: BigUnion[]; } | { name: '943'; children: BigUnion[]; } | { name: '944'; children: BigUnion[]; } | { name: '945'; children: BigUnion[]; } | { name: '946'; children: BigUnion[]; } | { name: '947'; children: BigUnion[]; } | { name: '948'; children: BigUnion[]; } | { name: '949'; children: BigUnion[]; } | { name: '950'; children: BigUnion[]; } | { name: '951'; children: BigUnion[]; } | { name: '952'; children: BigUnion[]; } | { name: '953'; children: BigUnion[]; } | { name: '954'; children: BigUnion[]; } | { name: '955'; children: BigUnion[]; } | { name: '956'; children: BigUnion[]; } | { name: '957'; children: BigUnion[]; } | { name: '958'; children: BigUnion[]; } | { name: '959'; children: BigUnion[]; } | { name: '960'; children: BigUnion[]; } | { name: '961'; children: BigUnion[]; } | { name: '962'; children: BigUnion[]; } | { name: '963'; children: BigUnion[]; } | { name: '964'; children: BigUnion[]; } | { name: '965'; children: BigUnion[]; } | { name: '966'; children: BigUnion[]; } | { name: '967'; children: BigUnion[]; } | { name: '968'; children: BigUnion[]; } | { name: '969'; children: BigUnion[]; } | { name: '970'; children: BigUnion[]; } | { name: '971'; children: BigUnion[]; } | { name: '972'; children: BigUnion[]; } | { name: '973'; children: BigUnion[]; } | { name: '974'; children: BigUnion[]; } | { name: '975'; children: BigUnion[]; } | { name: '976'; children: BigUnion[]; } | { name: '977'; children: BigUnion[]; } | { name: '978'; children: BigUnion[]; } | { name: '979'; children: BigUnion[]; } | { name: '980'; children: BigUnion[]; } | { name: '981'; children: BigUnion[]; } | { name: '982'; children: BigUnion[]; } | { name: '983'; children: BigUnion[]; } | { name: '984'; children: BigUnion[]; } | { name: '985'; children: BigUnion[]; } | { name: '986'; children: BigUnion[]; } | { name: '987'; children: BigUnion[]; } | { name: '988'; children: BigUnion[]; } | { name: '989'; children: BigUnion[]; } | { name: '990'; children: BigUnion[]; } | { name: '991'; children: BigUnion[]; } | { name: '992'; children: BigUnion[]; } | { name: '993'; children: BigUnion[]; } | { name: '994'; children: BigUnion[]; } | { name: '995'; children: BigUnion[]; } | { name: '996'; children: BigUnion[]; } | { name: '997'; children: BigUnion[]; } | { name: '998'; children: BigUnion[]; } | { name: '999'; children: BigUnion[]; } | { name: '1000'; children: BigUnion[]; } | { name: '1001'; children: BigUnion[]; } | { name: '1002'; children: BigUnion[]; } | { name: '1003'; children: BigUnion[]; } | { name: '1004'; children: BigUnion[]; } | { name: '1005'; children: BigUnion[]; } | { name: '1006'; children: BigUnion[]; } | { name: '1007'; children: BigUnion[]; } | { name: '1008'; children: BigUnion[]; } | { name: '1009'; children: BigUnion[]; } | { name: '1010'; children: BigUnion[]; } | { name: '1011'; children: BigUnion[]; } | { name: '1012'; children: BigUnion[]; } | { name: '1013'; children: BigUnion[]; } | { name: '1014'; children: BigUnion[]; } | { name: '1015'; children: BigUnion[]; } | { name: '1016'; children: BigUnion[]; } | { name: '1017'; children: BigUnion[]; } | { name: '1018'; children: BigUnion[]; } | { name: '1019'; children: BigUnion[]; } | { name: '1020'; children: BigUnion[]; } | { name: '1021'; children: BigUnion[]; } | { name: '1022'; children: BigUnion[]; } | { name: '1023'; children: BigUnion[]; } | { name: '1024'; children: BigUnion[]; } | { name: '1025'; children: BigUnion[]; } | { name: '1026'; children: BigUnion[]; } | { name: '1027'; children: BigUnion[]; } | { name: '1028'; children: BigUnion[]; } | { name: '1029'; children: BigUnion[]; } | { name: '1030'; children: BigUnion[]; } | { name: '1031'; children: BigUnion[]; } | { name: '1032'; children: BigUnion[]; } | { name: '1033'; children: BigUnion[]; } | { name: '1034'; children: BigUnion[]; } | { name: '1035'; children: BigUnion[]; } | { name: '1036'; children: BigUnion[]; } | { name: '1037'; children: BigUnion[]; } | { name: '1038'; children: BigUnion[]; } | { name: '1039'; children: BigUnion[]; } | { name: '1040'; children: BigUnion[]; } | { name: '1041'; children: BigUnion[]; } | { name: '1042'; children: BigUnion[]; } | { name: '1043'; children: BigUnion[]; } | { name: '1044'; children: BigUnion[]; } | { name: '1045'; children: BigUnion[]; } | { name: '1046'; children: BigUnion[]; } | { name: '1047'; children: BigUnion[]; } | { name: '1048'; children: BigUnion[]; } | { name: '1049'; children: BigUnion[]; } | { name: '1050'; children: BigUnion[]; } | { name: '1051'; children: BigUnion[]; } | { name: '1052'; children: BigUnion[]; } | { name: '1053'; children: BigUnion[]; } | { name: '1054'; children: BigUnion[]; } | { name: '1055'; children: BigUnion[]; } | { name: '1056'; children: BigUnion[]; } | { name: '1057'; children: BigUnion[]; } | { name: '1058'; children: BigUnion[]; } | { name: '1059'; children: BigUnion[]; } | { name: '1060'; children: BigUnion[]; } | { name: '1061'; children: BigUnion[]; } | { name: '1062'; children: BigUnion[]; } | { name: '1063'; children: BigUnion[]; } | { name: '1064'; children: BigUnion[]; } | { name: '1065'; children: BigUnion[]; } | { name: '1066'; children: BigUnion[]; } | { name: '1067'; children: BigUnion[]; } | { name: '1068'; children: BigUnion[]; } | { name: '1069'; children: BigUnion[]; } | { name: '1070'; children: BigUnion[]; } | { name: '1071'; children: BigUnion[]; } | { name: '1072'; children: BigUnion[]; } | { name: '1073'; children: BigUnion[]; } | { name: '1074'; children: BigUnion[]; } | { name: '1075'; children: BigUnion[]; } | { name: '1076'; children: BigUnion[]; } | { name: '1077'; children: BigUnion[]; } | { name: '1078'; children: BigUnion[]; } | { name: '1079'; children: BigUnion[]; } | { name: '1080'; children: BigUnion[]; } | { name: '1081'; children: BigUnion[]; } | { name: '1082'; children: BigUnion[]; } | { name: '1083'; children: BigUnion[]; } | { name: '1084'; children: BigUnion[]; } | { name: '1085'; children: BigUnion[]; } | { name: '1086'; children: BigUnion[]; } | { name: '1087'; children: BigUnion[]; } | { name: '1088'; children: BigUnion[]; } | { name: '1089'; children: BigUnion[]; } | { name: '1090'; children: BigUnion[]; } | { name: '1091'; children: BigUnion[]; } | { name: '1092'; children: BigUnion[]; } | { name: '1093'; children: BigUnion[]; } | { name: '1094'; children: BigUnion[]; } | { name: '1095'; children: BigUnion[]; } | { name: '1096'; children: BigUnion[]; } | { name: '1097'; children: BigUnion[]; } | { name: '1098'; children: BigUnion[]; } | { name: '1099'; children: BigUnion[]; } | { name: '1100'; children: BigUnion[]; } | { name: '1101'; children: BigUnion[]; } | { name: '1102'; children: BigUnion[]; } | { name: '1103'; children: BigUnion[]; } | { name: '1104'; children: BigUnion[]; } | { name: '1105'; children: BigUnion[]; } | { name: '1106'; children: BigUnion[]; } | { name: '1107'; children: BigUnion[]; } | { name: '1108'; children: BigUnion[]; } | { name: '1109'; children: BigUnion[]; } | { name: '1110'; children: BigUnion[]; } | { name: '1111'; children: BigUnion[]; } | { name: '1112'; children: BigUnion[]; } | { name: '1113'; children: BigUnion[]; } | { name: '1114'; children: BigUnion[]; } | { name: '1115'; children: BigUnion[]; } | { name: '1116'; children: BigUnion[]; } | { name: '1117'; children: BigUnion[]; } | { name: '1118'; children: BigUnion[]; } | { name: '1119'; children: BigUnion[]; } | { name: '1120'; children: BigUnion[]; } | { name: '1121'; children: BigUnion[]; } | { name: '1122'; children: BigUnion[]; } | { name: '1123'; children: BigUnion[]; } | { name: '1124'; children: BigUnion[]; } | { name: '1125'; children: BigUnion[]; } | { name: '1126'; children: BigUnion[]; } | { name: '1127'; children: BigUnion[]; } | { name: '1128'; children: BigUnion[]; } | { name: '1129'; children: BigUnion[]; } | { name: '1130'; children: BigUnion[]; } | { name: '1131'; children: BigUnion[]; } | { name: '1132'; children: BigUnion[]; } | { name: '1133'; children: BigUnion[]; } | { name: '1134'; children: BigUnion[]; } | { name: '1135'; children: BigUnion[]; } | { name: '1136'; children: BigUnion[]; } | { name: '1137'; children: BigUnion[]; } | { name: '1138'; children: BigUnion[]; } | { name: '1139'; children: BigUnion[]; } | { name: '1140'; children: BigUnion[]; } | { name: '1141'; children: BigUnion[]; } | { name: '1142'; children: BigUnion[]; } | { name: '1143'; children: BigUnion[]; } | { name: '1144'; children: BigUnion[]; } | { name: '1145'; children: BigUnion[]; } | { name: '1146'; children: BigUnion[]; } | { name: '1147'; children: BigUnion[]; } | { name: '1148'; children: BigUnion[]; } | { name: '1149'; children: BigUnion[]; } | { name: '1150'; children: BigUnion[]; } | { name: '1151'; children: BigUnion[]; } | { name: '1152'; children: BigUnion[]; } | { name: '1153'; children: BigUnion[]; } | { name: '1154'; children: BigUnion[]; } | { name: '1155'; children: BigUnion[]; } | { name: '1156'; children: BigUnion[]; } | { name: '1157'; children: BigUnion[]; } | { name: '1158'; children: BigUnion[]; } | { name: '1159'; children: BigUnion[]; } | { name: '1160'; children: BigUnion[]; } | { name: '1161'; children: BigUnion[]; } | { name: '1162'; children: BigUnion[]; } | { name: '1163'; children: BigUnion[]; } | { name: '1164'; children: BigUnion[]; } | { name: '1165'; children: BigUnion[]; } | { name: '1166'; children: BigUnion[]; } | { name: '1167'; children: BigUnion[]; } | { name: '1168'; children: BigUnion[]; } | { name: '1169'; children: BigUnion[]; } | { name: '1170'; children: BigUnion[]; } | { name: '1171'; children: BigUnion[]; } | { name: '1172'; children: BigUnion[]; } | { name: '1173'; children: BigUnion[]; } | { name: '1174'; children: BigUnion[]; } | { name: '1175'; children: BigUnion[]; } | { name: '1176'; children: BigUnion[]; } | { name: '1177'; children: BigUnion[]; } | { name: '1178'; children: BigUnion[]; } | { name: '1179'; children: BigUnion[]; } | { name: '1180'; children: BigUnion[]; } | { name: '1181'; children: BigUnion[]; } | { name: '1182'; children: BigUnion[]; } | { name: '1183'; children: BigUnion[]; } | { name: '1184'; children: BigUnion[]; } | { name: '1185'; children: BigUnion[]; } | { name: '1186'; children: BigUnion[]; } | { name: '1187'; children: BigUnion[]; } | { name: '1188'; children: BigUnion[]; } | { name: '1189'; children: BigUnion[]; } | { name: '1190'; children: BigUnion[]; } | { name: '1191'; children: BigUnion[]; } | { name: '1192'; children: BigUnion[]; } | { name: '1193'; children: BigUnion[]; } | { name: '1194'; children: BigUnion[]; } | { name: '1195'; children: BigUnion[]; } | { name: '1196'; children: BigUnion[]; } | { name: '1197'; children: BigUnion[]; } | { name: '1198'; children: BigUnion[]; } | { name: '1199'; children: BigUnion[]; } | { name: '1200'; children: BigUnion[]; } | { name: '1201'; children: BigUnion[]; } | { name: '1202'; children: BigUnion[]; } | { name: '1203'; children: BigUnion[]; } | { name: '1204'; children: BigUnion[]; } | { name: '1205'; children: BigUnion[]; } | { name: '1206'; children: BigUnion[]; } | { name: '1207'; children: BigUnion[]; } | { name: '1208'; children: BigUnion[]; } | { name: '1209'; children: BigUnion[]; } | { name: '1210'; children: BigUnion[]; } | { name: '1211'; children: BigUnion[]; } | { name: '1212'; children: BigUnion[]; } | { name: '1213'; children: BigUnion[]; } | { name: '1214'; children: BigUnion[]; } | { name: '1215'; children: BigUnion[]; } | { name: '1216'; children: BigUnion[]; } | { name: '1217'; children: BigUnion[]; } | { name: '1218'; children: BigUnion[]; } | { name: '1219'; children: BigUnion[]; } | { name: '1220'; children: BigUnion[]; } | { name: '1221'; children: BigUnion[]; } | { name: '1222'; children: BigUnion[]; } | { name: '1223'; children: BigUnion[]; } | { name: '1224'; children: BigUnion[]; } | { name: '1225'; children: BigUnion[]; } | { name: '1226'; children: BigUnion[]; } | { name: '1227'; children: BigUnion[]; } | { name: '1228'; children: BigUnion[]; } | { name: '1229'; children: BigUnion[]; } | { name: '1230'; children: BigUnion[]; } | { name: '1231'; children: BigUnion[]; } | { name: '1232'; children: BigUnion[]; } | { name: '1233'; children: BigUnion[]; } | { name: '1234'; children: BigUnion[]; } | { name: '1235'; children: BigUnion[]; } | { name: '1236'; children: BigUnion[]; } | { name: '1237'; children: BigUnion[]; } | { name: '1238'; children: BigUnion[]; } | { name: '1239'; children: BigUnion[]; } | { name: '1240'; children: BigUnion[]; } | { name: '1241'; children: BigUnion[]; } | { name: '1242'; children: BigUnion[]; } | { name: '1243'; children: BigUnion[]; } | { name: '1244'; children: BigUnion[]; } | { name: '1245'; children: BigUnion[]; } | { name: '1246'; children: BigUnion[]; } | { name: '1247'; children: BigUnion[]; } | { name: '1248'; children: BigUnion[]; } | { name: '1249'; children: BigUnion[]; } | { name: '1250'; children: BigUnion[]; } | { name: '1251'; children: BigUnion[]; } | { name: '1252'; children: BigUnion[]; } | { name: '1253'; children: BigUnion[]; } | { name: '1254'; children: BigUnion[]; } | { name: '1255'; children: BigUnion[]; } | { name: '1256'; children: BigUnion[]; } | { name: '1257'; children: BigUnion[]; } | { name: '1258'; children: BigUnion[]; } | { name: '1259'; children: BigUnion[]; } | { name: '1260'; children: BigUnion[]; } | { name: '1261'; children: BigUnion[]; } | { name: '1262'; children: BigUnion[]; } | { name: '1263'; children: BigUnion[]; } | { name: '1264'; children: BigUnion[]; } | { name: '1265'; children: BigUnion[]; } | { name: '1266'; children: BigUnion[]; } | { name: '1267'; children: BigUnion[]; } | { name: '1268'; children: BigUnion[]; } | { name: '1269'; children: BigUnion[]; } | { name: '1270'; children: BigUnion[]; } | { name: '1271'; children: BigUnion[]; } | { name: '1272'; children: BigUnion[]; } | { name: '1273'; children: BigUnion[]; } | { name: '1274'; children: BigUnion[]; } | { name: '1275'; children: BigUnion[]; } | { name: '1276'; children: BigUnion[]; } | { name: '1277'; children: BigUnion[]; } | { name: '1278'; children: BigUnion[]; } | { name: '1279'; children: BigUnion[]; } | { name: '1280'; children: BigUnion[]; } | { name: '1281'; children: BigUnion[]; } | { name: '1282'; children: BigUnion[]; } | { name: '1283'; children: BigUnion[]; } | { name: '1284'; children: BigUnion[]; } | { name: '1285'; children: BigUnion[]; } | { name: '1286'; children: BigUnion[]; } | { name: '1287'; children: BigUnion[]; } | { name: '1288'; children: BigUnion[]; } | { name: '1289'; children: BigUnion[]; } | { name: '1290'; children: BigUnion[]; } | { name: '1291'; children: BigUnion[]; } | { name: '1292'; children: BigUnion[]; } | { name: '1293'; children: BigUnion[]; } | { name: '1294'; children: BigUnion[]; } | { name: '1295'; children: BigUnion[]; } | { name: '1296'; children: BigUnion[]; } | { name: '1297'; children: BigUnion[]; } | { name: '1298'; children: BigUnion[]; } | { name: '1299'; children: BigUnion[]; } | { name: '1300'; children: BigUnion[]; } | { name: '1301'; children: BigUnion[]; } | { name: '1302'; children: BigUnion[]; } | { name: '1303'; children: BigUnion[]; } | { name: '1304'; children: BigUnion[]; } | { name: '1305'; children: BigUnion[]; } | { name: '1306'; children: BigUnion[]; } | { name: '1307'; children: BigUnion[]; } | { name: '1308'; children: BigUnion[]; } | { name: '1309'; children: BigUnion[]; } | { name: '1310'; children: BigUnion[]; } | { name: '1311'; children: BigUnion[]; } | { name: '1312'; children: BigUnion[]; } | { name: '1313'; children: BigUnion[]; } | { name: '1314'; children: BigUnion[]; } | { name: '1315'; children: BigUnion[]; } | { name: '1316'; children: BigUnion[]; } | { name: '1317'; children: BigUnion[]; } | { name: '1318'; children: BigUnion[]; } | { name: '1319'; children: BigUnion[]; } | { name: '1320'; children: BigUnion[]; } | { name: '1321'; children: BigUnion[]; } | { name: '1322'; children: BigUnion[]; } | { name: '1323'; children: BigUnion[]; } | { name: '1324'; children: BigUnion[]; } | { name: '1325'; children: BigUnion[]; } | { name: '1326'; children: BigUnion[]; } | { name: '1327'; children: BigUnion[]; } | { name: '1328'; children: BigUnion[]; } | { name: '1329'; children: BigUnion[]; } | { name: '1330'; children: BigUnion[]; } | { name: '1331'; children: BigUnion[]; } | { name: '1332'; children: BigUnion[]; } | { name: '1333'; children: BigUnion[]; } | { name: '1334'; children: BigUnion[]; } | { name: '1335'; children: BigUnion[]; } | { name: '1336'; children: BigUnion[]; } | { name: '1337'; children: BigUnion[]; } | { name: '1338'; children: BigUnion[]; } | { name: '1339'; children: BigUnion[]; } | { name: '1340'; children: BigUnion[]; } | { name: '1341'; children: BigUnion[]; } | { name: '1342'; children: BigUnion[]; } | { name: '1343'; children: BigUnion[]; } | { name: '1344'; children: BigUnion[]; } | { name: '1345'; children: BigUnion[]; } | { name: '1346'; children: BigUnion[]; } | { name: '1347'; children: BigUnion[]; } | { name: '1348'; children: BigUnion[]; } | { name: '1349'; children: BigUnion[]; } | { name: '1350'; children: BigUnion[]; } | { name: '1351'; children: BigUnion[]; } | { name: '1352'; children: BigUnion[]; } | { name: '1353'; children: BigUnion[]; } | { name: '1354'; children: BigUnion[]; } | { name: '1355'; children: BigUnion[]; } | { name: '1356'; children: BigUnion[]; } | { name: '1357'; children: BigUnion[]; } | { name: '1358'; children: BigUnion[]; } | { name: '1359'; children: BigUnion[]; } | { name: '1360'; children: BigUnion[]; } | { name: '1361'; children: BigUnion[]; } | { name: '1362'; children: BigUnion[]; } | { name: '1363'; children: BigUnion[]; } | { name: '1364'; children: BigUnion[]; } | { name: '1365'; children: BigUnion[]; } | { name: '1366'; children: BigUnion[]; } | { name: '1367'; children: BigUnion[]; } | { name: '1368'; children: BigUnion[]; } | { name: '1369'; children: BigUnion[]; } | { name: '1370'; children: BigUnion[]; } | { name: '1371'; children: BigUnion[]; } | { name: '1372'; children: BigUnion[]; } | { name: '1373'; children: BigUnion[]; } | { name: '1374'; children: BigUnion[]; } | { name: '1375'; children: BigUnion[]; } | { name: '1376'; children: BigUnion[]; } | { name: '1377'; children: BigUnion[]; } | { name: '1378'; children: BigUnion[]; } | { name: '1379'; children: BigUnion[]; } | { name: '1380'; children: BigUnion[]; } | { name: '1381'; children: BigUnion[]; } | { name: '1382'; children: BigUnion[]; } | { name: '1383'; children: BigUnion[]; } | { name: '1384'; children: BigUnion[]; } | { name: '1385'; children: BigUnion[]; } | { name: '1386'; children: BigUnion[]; } | { name: '1387'; children: BigUnion[]; } | { name: '1388'; children: BigUnion[]; } | { name: '1389'; children: BigUnion[]; } | { name: '1390'; children: BigUnion[]; } | { name: '1391'; children: BigUnion[]; } | { name: '1392'; children: BigUnion[]; } | { name: '1393'; children: BigUnion[]; } | { name: '1394'; children: BigUnion[]; } | { name: '1395'; children: BigUnion[]; } | { name: '1396'; children: BigUnion[]; } | { name: '1397'; children: BigUnion[]; } | { name: '1398'; children: BigUnion[]; } | { name: '1399'; children: BigUnion[]; } | { name: '1400'; children: BigUnion[]; } | { name: '1401'; children: BigUnion[]; } | { name: '1402'; children: BigUnion[]; } | { name: '1403'; children: BigUnion[]; } | { name: '1404'; children: BigUnion[]; } | { name: '1405'; children: BigUnion[]; } | { name: '1406'; children: BigUnion[]; } | { name: '1407'; children: BigUnion[]; } | { name: '1408'; children: BigUnion[]; } | { name: '1409'; children: BigUnion[]; } | { name: '1410'; children: BigUnion[]; } | { name: '1411'; children: BigUnion[]; } | { name: '1412'; children: BigUnion[]; } | { name: '1413'; children: BigUnion[]; } | { name: '1414'; children: BigUnion[]; } | { name: '1415'; children: BigUnion[]; } | { name: '1416'; children: BigUnion[]; } | { name: '1417'; children: BigUnion[]; } | { name: '1418'; children: BigUnion[]; } | { name: '1419'; children: BigUnion[]; } | { name: '1420'; children: BigUnion[]; } | { name: '1421'; children: BigUnion[]; } | { name: '1422'; children: BigUnion[]; } | { name: '1423'; children: BigUnion[]; } | { name: '1424'; children: BigUnion[]; } | { name: '1425'; children: BigUnion[]; } | { name: '1426'; children: BigUnion[]; } | { name: '1427'; children: BigUnion[]; } | { name: '1428'; children: BigUnion[]; } | { name: '1429'; children: BigUnion[]; } | { name: '1430'; children: BigUnion[]; } | { name: '1431'; children: BigUnion[]; } | { name: '1432'; children: BigUnion[]; } | { name: '1433'; children: BigUnion[]; } | { name: '1434'; children: BigUnion[]; } | { name: '1435'; children: BigUnion[]; } | { name: '1436'; children: BigUnion[]; } | { name: '1437'; children: BigUnion[]; } | { name: '1438'; children: BigUnion[]; } | { name: '1439'; children: BigUnion[]; } | { name: '1440'; children: BigUnion[]; } | { name: '1441'; children: BigUnion[]; } | { name: '1442'; children: BigUnion[]; } | { name: '1443'; children: BigUnion[]; } | { name: '1444'; children: BigUnion[]; } | { name: '1445'; children: BigUnion[]; } | { name: '1446'; children: BigUnion[]; } | { name: '1447'; children: BigUnion[]; } | { name: '1448'; children: BigUnion[]; } | { name: '1449'; children: BigUnion[]; } | { name: '1450'; children: BigUnion[]; } | { name: '1451'; children: BigUnion[]; } | { name: '1452'; children: BigUnion[]; } | { name: '1453'; children: BigUnion[]; } | { name: '1454'; children: BigUnion[]; } | { name: '1455'; children: BigUnion[]; } | { name: '1456'; children: BigUnion[]; } | { name: '1457'; children: BigUnion[]; } | { name: '1458'; children: BigUnion[]; } | { name: '1459'; children: BigUnion[]; } | { name: '1460'; children: BigUnion[]; } | { name: '1461'; children: BigUnion[]; } | { name: '1462'; children: BigUnion[]; } | { name: '1463'; children: BigUnion[]; } | { name: '1464'; children: BigUnion[]; } | { name: '1465'; children: BigUnion[]; } | { name: '1466'; children: BigUnion[]; } | { name: '1467'; children: BigUnion[]; } | { name: '1468'; children: BigUnion[]; } | { name: '1469'; children: BigUnion[]; } | { name: '1470'; children: BigUnion[]; } | { name: '1471'; children: BigUnion[]; } | { name: '1472'; children: BigUnion[]; } | { name: '1473'; children: BigUnion[]; } | { name: '1474'; children: BigUnion[]; } | { name: '1475'; children: BigUnion[]; } | { name: '1476'; children: BigUnion[]; } | { name: '1477'; children: BigUnion[]; } | { name: '1478'; children: BigUnion[]; } | { name: '1479'; children: BigUnion[]; } | { name: '1480'; children: BigUnion[]; } | { name: '1481'; children: BigUnion[]; } | { name: '1482'; children: BigUnion[]; } | { name: '1483'; children: BigUnion[]; } | { name: '1484'; children: BigUnion[]; } | { name: '1485'; children: BigUnion[]; } | { name: '1486'; children: BigUnion[]; } | { name: '1487'; children: BigUnion[]; } | { name: '1488'; children: BigUnion[]; } | { name: '1489'; children: BigUnion[]; } | { name: '1490'; children: BigUnion[]; } | { name: '1491'; children: BigUnion[]; } | { name: '1492'; children: BigUnion[]; } | { name: '1493'; children: BigUnion[]; } | { name: '1494'; children: BigUnion[]; } | { name: '1495'; children: BigUnion[]; } | { name: '1496'; children: BigUnion[]; } | { name: '1497'; children: BigUnion[]; } | { name: '1498'; children: BigUnion[]; } | { name: '1499'; children: BigUnion[]; } | { name: '1500'; children: BigUnion[]; } | { name: '1501'; children: BigUnion[]; } | { name: '1502'; children: BigUnion[]; } | { name: '1503'; children: BigUnion[]; } | { name: '1504'; children: BigUnion[]; } | { name: '1505'; children: BigUnion[]; } | { name: '1506'; children: BigUnion[]; } | { name: '1507'; children: BigUnion[]; } | { name: '1508'; children: BigUnion[]; } | { name: '1509'; children: BigUnion[]; } | { name: '1510'; children: BigUnion[]; } | { name: '1511'; children: BigUnion[]; } | { name: '1512'; children: BigUnion[]; } | { name: '1513'; children: BigUnion[]; } | { name: '1514'; children: BigUnion[]; } | { name: '1515'; children: BigUnion[]; } | { name: '1516'; children: BigUnion[]; } | { name: '1517'; children: BigUnion[]; } | { name: '1518'; children: BigUnion[]; } | { name: '1519'; children: BigUnion[]; } | { name: '1520'; children: BigUnion[]; } | { name: '1521'; children: BigUnion[]; } | { name: '1522'; children: BigUnion[]; } | { name: '1523'; children: BigUnion[]; } | { name: '1524'; children: BigUnion[]; } | { name: '1525'; children: BigUnion[]; } | { name: '1526'; children: BigUnion[]; } | { name: '1527'; children: BigUnion[]; } | { name: '1528'; children: BigUnion[]; } | { name: '1529'; children: BigUnion[]; } | { name: '1530'; children: BigUnion[]; } | { name: '1531'; children: BigUnion[]; } | { name: '1532'; children: BigUnion[]; } | { name: '1533'; children: BigUnion[]; } | { name: '1534'; children: BigUnion[]; } | { name: '1535'; children: BigUnion[]; } | { name: '1536'; children: BigUnion[]; } | { name: '1537'; children: BigUnion[]; } | { name: '1538'; children: BigUnion[]; } | { name: '1539'; children: BigUnion[]; } | { name: '1540'; children: BigUnion[]; } | { name: '1541'; children: BigUnion[]; } | { name: '1542'; children: BigUnion[]; } | { name: '1543'; children: BigUnion[]; } | { name: '1544'; children: BigUnion[]; } | { name: '1545'; children: BigUnion[]; } | { name: '1546'; children: BigUnion[]; } | { name: '1547'; children: BigUnion[]; } | { name: '1548'; children: BigUnion[]; } | { name: '1549'; children: BigUnion[]; } | { name: '1550'; children: BigUnion[]; } | { name: '1551'; children: BigUnion[]; } | { name: '1552'; children: BigUnion[]; } | { name: '1553'; children: BigUnion[]; } | { name: '1554'; children: BigUnion[]; } | { name: '1555'; children: BigUnion[]; } | { name: '1556'; children: BigUnion[]; } | { name: '1557'; children: BigUnion[]; } | { name: '1558'; children: BigUnion[]; } | { name: '1559'; children: BigUnion[]; } | { name: '1560'; children: BigUnion[]; } | { name: '1561'; children: BigUnion[]; } | { name: '1562'; children: BigUnion[]; } | { name: '1563'; children: BigUnion[]; } | { name: '1564'; children: BigUnion[]; } | { name: '1565'; children: BigUnion[]; } | { name: '1566'; children: BigUnion[]; } | { name: '1567'; children: BigUnion[]; } | { name: '1568'; children: BigUnion[]; } | { name: '1569'; children: BigUnion[]; } | { name: '1570'; children: BigUnion[]; } | { name: '1571'; children: BigUnion[]; } | { name: '1572'; children: BigUnion[]; } | { name: '1573'; children: BigUnion[]; } | { name: '1574'; children: BigUnion[]; } | { name: '1575'; children: BigUnion[]; } | { name: '1576'; children: BigUnion[]; } | { name: '1577'; children: BigUnion[]; } | { name: '1578'; children: BigUnion[]; } | { name: '1579'; children: BigUnion[]; } | { name: '1580'; children: BigUnion[]; } | { name: '1581'; children: BigUnion[]; } | { name: '1582'; children: BigUnion[]; } | { name: '1583'; children: BigUnion[]; } | { name: '1584'; children: BigUnion[]; } | { name: '1585'; children: BigUnion[]; } | { name: '1586'; children: BigUnion[]; } | { name: '1587'; children: BigUnion[]; } | { name: '1588'; children: BigUnion[]; } | { name: '1589'; children: BigUnion[]; } | { name: '1590'; children: BigUnion[]; } | { name: '1591'; children: BigUnion[]; } | { name: '1592'; children: BigUnion[]; } | { name: '1593'; children: BigUnion[]; } | { name: '1594'; children: BigUnion[]; } | { name: '1595'; children: BigUnion[]; } | { name: '1596'; children: BigUnion[]; } | { name: '1597'; children: BigUnion[]; } | { name: '1598'; children: BigUnion[]; } | { name: '1599'; children: BigUnion[]; } | { name: '1600'; children: BigUnion[]; } | { name: '1601'; children: BigUnion[]; } | { name: '1602'; children: BigUnion[]; } | { name: '1603'; children: BigUnion[]; } | { name: '1604'; children: BigUnion[]; } | { name: '1605'; children: BigUnion[]; } | { name: '1606'; children: BigUnion[]; } | { name: '1607'; children: BigUnion[]; } | { name: '1608'; children: BigUnion[]; } | { name: '1609'; children: BigUnion[]; } | { name: '1610'; children: BigUnion[]; } | { name: '1611'; children: BigUnion[]; } | { name: '1612'; children: BigUnion[]; } | { name: '1613'; children: BigUnion[]; } | { name: '1614'; children: BigUnion[]; } | { name: '1615'; children: BigUnion[]; } | { name: '1616'; children: BigUnion[]; } | { name: '1617'; children: BigUnion[]; } | { name: '1618'; children: BigUnion[]; } | { name: '1619'; children: BigUnion[]; } | { name: '1620'; children: BigUnion[]; } | { name: '1621'; children: BigUnion[]; } | { name: '1622'; children: BigUnion[]; } | { name: '1623'; children: BigUnion[]; } | { name: '1624'; children: BigUnion[]; } | { name: '1625'; children: BigUnion[]; } | { name: '1626'; children: BigUnion[]; } | { name: '1627'; children: BigUnion[]; } | { name: '1628'; children: BigUnion[]; } | { name: '1629'; children: BigUnion[]; } | { name: '1630'; children: BigUnion[]; } | { name: '1631'; children: BigUnion[]; } | { name: '1632'; children: BigUnion[]; } | { name: '1633'; children: BigUnion[]; } | { name: '1634'; children: BigUnion[]; } | { name: '1635'; children: BigUnion[]; } | { name: '1636'; children: BigUnion[]; } | { name: '1637'; children: BigUnion[]; } | { name: '1638'; children: BigUnion[]; } | { name: '1639'; children: BigUnion[]; } | { name: '1640'; children: BigUnion[]; } | { name: '1641'; children: BigUnion[]; } | { name: '1642'; children: BigUnion[]; } | { name: '1643'; children: BigUnion[]; } | { name: '1644'; children: BigUnion[]; } | { name: '1645'; children: BigUnion[]; } | { name: '1646'; children: BigUnion[]; } | { name: '1647'; children: BigUnion[]; } | { name: '1648'; children: BigUnion[]; } | { name: '1649'; children: BigUnion[]; } | { name: '1650'; children: BigUnion[]; } | { name: '1651'; children: BigUnion[]; } | { name: '1652'; children: BigUnion[]; } | { name: '1653'; children: BigUnion[]; } | { name: '1654'; children: BigUnion[]; } | { name: '1655'; children: BigUnion[]; } | { name: '1656'; children: BigUnion[]; } | { name: '1657'; children: BigUnion[]; } | { name: '1658'; children: BigUnion[]; } | { name: '1659'; children: BigUnion[]; } | { name: '1660'; children: BigUnion[]; } | { name: '1661'; children: BigUnion[]; } | { name: '1662'; children: BigUnion[]; } | { name: '1663'; children: BigUnion[]; } | { name: '1664'; children: BigUnion[]; } | { name: '1665'; children: BigUnion[]; } | { name: '1666'; children: BigUnion[]; } | { name: '1667'; children: BigUnion[]; } | { name: '1668'; children: BigUnion[]; } | { name: '1669'; children: BigUnion[]; } | { name: '1670'; children: BigUnion[]; } | { name: '1671'; children: BigUnion[]; } | { name: '1672'; children: BigUnion[]; } | { name: '1673'; children: BigUnion[]; } | { name: '1674'; children: BigUnion[]; } | { name: '1675'; children: BigUnion[]; } | { name: '1676'; children: BigUnion[]; } | { name: '1677'; children: BigUnion[]; } | { name: '1678'; children: BigUnion[]; } | { name: '1679'; children: BigUnion[]; } | { name: '1680'; children: BigUnion[]; } | { name: '1681'; children: BigUnion[]; } | { name: '1682'; children: BigUnion[]; } | { name: '1683'; children: BigUnion[]; } | { name: '1684'; children: BigUnion[]; } | { name: '1685'; children: BigUnion[]; } | { name: '1686'; children: BigUnion[]; } | { name: '1687'; children: BigUnion[]; } | { name: '1688'; children: BigUnion[]; } | { name: '1689'; children: BigUnion[]; } | { name: '1690'; children: BigUnion[]; } | { name: '1691'; children: BigUnion[]; } | { name: '1692'; children: BigUnion[]; } | { name: '1693'; children: BigUnion[]; } | { name: '1694'; children: BigUnion[]; } | { name: '1695'; children: BigUnion[]; } | { name: '1696'; children: BigUnion[]; } | { name: '1697'; children: BigUnion[]; } | { name: '1698'; children: BigUnion[]; } | { name: '1699'; children: BigUnion[]; } | { name: '1700'; children: BigUnion[]; } | { name: '1701'; children: BigUnion[]; } | { name: '1702'; children: BigUnion[]; } | { name: '1703'; children: BigUnion[]; } | { name: '1704'; children: BigUnion[]; } | { name: '1705'; children: BigUnion[]; } | { name: '1706'; children: BigUnion[]; } | { name: '1707'; children: BigUnion[]; } | { name: '1708'; children: BigUnion[]; } | { name: '1709'; children: BigUnion[]; } | { name: '1710'; children: BigUnion[]; } | { name: '1711'; children: BigUnion[]; } | { name: '1712'; children: BigUnion[]; } | { name: '1713'; children: BigUnion[]; } | { name: '1714'; children: BigUnion[]; } | { name: '1715'; children: BigUnion[]; } | { name: '1716'; children: BigUnion[]; } | { name: '1717'; children: BigUnion[]; } | { name: '1718'; children: BigUnion[]; } | { name: '1719'; children: BigUnion[]; } | { name: '1720'; children: BigUnion[]; } | { name: '1721'; children: BigUnion[]; } | { name: '1722'; children: BigUnion[]; } | { name: '1723'; children: BigUnion[]; } | { name: '1724'; children: BigUnion[]; } | { name: '1725'; children: BigUnion[]; } | { name: '1726'; children: BigUnion[]; } | { name: '1727'; children: BigUnion[]; } | { name: '1728'; children: BigUnion[]; } | { name: '1729'; children: BigUnion[]; } | { name: '1730'; children: BigUnion[]; } | { name: '1731'; children: BigUnion[]; } | { name: '1732'; children: BigUnion[]; } | { name: '1733'; children: BigUnion[]; } | { name: '1734'; children: BigUnion[]; } | { name: '1735'; children: BigUnion[]; } | { name: '1736'; children: BigUnion[]; } | { name: '1737'; children: BigUnion[]; } | { name: '1738'; children: BigUnion[]; } | { name: '1739'; children: BigUnion[]; } | { name: '1740'; children: BigUnion[]; } | { name: '1741'; children: BigUnion[]; } | { name: '1742'; children: BigUnion[]; } | { name: '1743'; children: BigUnion[]; } | { name: '1744'; children: BigUnion[]; } | { name: '1745'; children: BigUnion[]; } | { name: '1746'; children: BigUnion[]; } | { name: '1747'; children: BigUnion[]; } | { name: '1748'; children: BigUnion[]; } | { name: '1749'; children: BigUnion[]; } | { name: '1750'; children: BigUnion[]; } | { name: '1751'; children: BigUnion[]; } | { name: '1752'; children: BigUnion[]; } | { name: '1753'; children: BigUnion[]; } | { name: '1754'; children: BigUnion[]; } | { name: '1755'; children: BigUnion[]; } | { name: '1756'; children: BigUnion[]; } | { name: '1757'; children: BigUnion[]; } | { name: '1758'; children: BigUnion[]; } | { name: '1759'; children: BigUnion[]; } | { name: '1760'; children: BigUnion[]; } | { name: '1761'; children: BigUnion[]; } | { name: '1762'; children: BigUnion[]; } | { name: '1763'; children: BigUnion[]; } | { name: '1764'; children: BigUnion[]; } | { name: '1765'; children: BigUnion[]; } | { name: '1766'; children: BigUnion[]; } | { name: '1767'; children: BigUnion[]; } | { name: '1768'; children: BigUnion[]; } | { name: '1769'; children: BigUnion[]; } | { name: '1770'; children: BigUnion[]; } | { name: '1771'; children: BigUnion[]; } | { name: '1772'; children: BigUnion[]; } | { name: '1773'; children: BigUnion[]; } | { name: '1774'; children: BigUnion[]; } | { name: '1775'; children: BigUnion[]; } | { name: '1776'; children: BigUnion[]; } | { name: '1777'; children: BigUnion[]; } | { name: '1778'; children: BigUnion[]; } | { name: '1779'; children: BigUnion[]; } | { name: '1780'; children: BigUnion[]; } | { name: '1781'; children: BigUnion[]; } | { name: '1782'; children: BigUnion[]; } | { name: '1783'; children: BigUnion[]; } | { name: '1784'; children: BigUnion[]; } | { name: '1785'; children: BigUnion[]; } | { name: '1786'; children: BigUnion[]; } | { name: '1787'; children: BigUnion[]; } | { name: '1788'; children: BigUnion[]; } | { name: '1789'; children: BigUnion[]; } | { name: '1790'; children: BigUnion[]; } | { name: '1791'; children: BigUnion[]; } | { name: '1792'; children: BigUnion[]; } | { name: '1793'; children: BigUnion[]; } | { name: '1794'; children: BigUnion[]; } | { name: '1795'; children: BigUnion[]; } | { name: '1796'; children: BigUnion[]; } | { name: '1797'; children: BigUnion[]; } | { name: '1798'; children: BigUnion[]; } | { name: '1799'; children: BigUnion[]; } | { name: '1800'; children: BigUnion[]; } | { name: '1801'; children: BigUnion[]; } | { name: '1802'; children: BigUnion[]; } | { name: '1803'; children: BigUnion[]; } | { name: '1804'; children: BigUnion[]; } | { name: '1805'; children: BigUnion[]; } | { name: '1806'; children: BigUnion[]; } | { name: '1807'; children: BigUnion[]; } | { name: '1808'; children: BigUnion[]; } | { name: '1809'; children: BigUnion[]; } | { name: '1810'; children: BigUnion[]; } | { name: '1811'; children: BigUnion[]; } | { name: '1812'; children: BigUnion[]; } | { name: '1813'; children: BigUnion[]; } | { name: '1814'; children: BigUnion[]; } | { name: '1815'; children: BigUnion[]; } | { name: '1816'; children: BigUnion[]; } | { name: '1817'; children: BigUnion[]; } | { name: '1818'; children: BigUnion[]; } | { name: '1819'; children: BigUnion[]; } | { name: '1820'; children: BigUnion[]; } | { name: '1821'; children: BigUnion[]; } | { name: '1822'; children: BigUnion[]; } | { name: '1823'; children: BigUnion[]; } | { name: '1824'; children: BigUnion[]; } | { name: '1825'; children: BigUnion[]; } | { name: '1826'; children: BigUnion[]; } | { name: '1827'; children: BigUnion[]; } | { name: '1828'; children: BigUnion[]; } | { name: '1829'; children: BigUnion[]; } | { name: '1830'; children: BigUnion[]; } | { name: '1831'; children: BigUnion[]; } | { name: '1832'; children: BigUnion[]; } | { name: '1833'; children: BigUnion[]; } | { name: '1834'; children: BigUnion[]; } | { name: '1835'; children: BigUnion[]; } | { name: '1836'; children: BigUnion[]; } | { name: '1837'; children: BigUnion[]; } | { name: '1838'; children: BigUnion[]; } | { name: '1839'; children: BigUnion[]; } | { name: '1840'; children: BigUnion[]; } | { name: '1841'; children: BigUnion[]; } | { name: '1842'; children: BigUnion[]; } | { name: '1843'; children: BigUnion[]; } | { name: '1844'; children: BigUnion[]; } | { name: '1845'; children: BigUnion[]; } | { name: '1846'; children: BigUnion[]; } | { name: '1847'; children: BigUnion[]; } | { name: '1848'; children: BigUnion[]; } | { name: '1849'; children: BigUnion[]; } | { name: '1850'; children: BigUnion[]; } | { name: '1851'; children: BigUnion[]; } | { name: '1852'; children: BigUnion[]; } | { name: '1853'; children: BigUnion[]; } | { name: '1854'; children: BigUnion[]; } | { name: '1855'; children: BigUnion[]; } | { name: '1856'; children: BigUnion[]; } | { name: '1857'; children: BigUnion[]; } | { name: '1858'; children: BigUnion[]; } | { name: '1859'; children: BigUnion[]; } | { name: '1860'; children: BigUnion[]; } | { name: '1861'; children: BigUnion[]; } | { name: '1862'; children: BigUnion[]; } | { name: '1863'; children: BigUnion[]; } | { name: '1864'; children: BigUnion[]; } | { name: '1865'; children: BigUnion[]; } | { name: '1866'; children: BigUnion[]; } | { name: '1867'; children: BigUnion[]; } | { name: '1868'; children: BigUnion[]; } | { name: '1869'; children: BigUnion[]; } | { name: '1870'; children: BigUnion[]; } | { name: '1871'; children: BigUnion[]; } | { name: '1872'; children: BigUnion[]; } | { name: '1873'; children: BigUnion[]; } | { name: '1874'; children: BigUnion[]; } | { name: '1875'; children: BigUnion[]; } | { name: '1876'; children: BigUnion[]; } | { name: '1877'; children: BigUnion[]; } | { name: '1878'; children: BigUnion[]; } | { name: '1879'; children: BigUnion[]; } | { name: '1880'; children: BigUnion[]; } | { name: '1881'; children: BigUnion[]; } | { name: '1882'; children: BigUnion[]; } | { name: '1883'; children: BigUnion[]; } | { name: '1884'; children: BigUnion[]; } | { name: '1885'; children: BigUnion[]; } | { name: '1886'; children: BigUnion[]; } | { name: '1887'; children: BigUnion[]; } | { name: '1888'; children: BigUnion[]; } | { name: '1889'; children: BigUnion[]; } | { name: '1890'; children: BigUnion[]; } | { name: '1891'; children: BigUnion[]; } | { name: '1892'; children: BigUnion[]; } | { name: '1893'; children: BigUnion[]; } | { name: '1894'; children: BigUnion[]; } | { name: '1895'; children: BigUnion[]; } | { name: '1896'; children: BigUnion[]; } | { name: '1897'; children: BigUnion[]; } | { name: '1898'; children: BigUnion[]; } | { name: '1899'; children: BigUnion[]; } | { name: '1900'; children: BigUnion[]; } | { name: '1901'; children: BigUnion[]; } | { name: '1902'; children: BigUnion[]; } | { name: '1903'; children: BigUnion[]; } | { name: '1904'; children: BigUnion[]; } | { name: '1905'; children: BigUnion[]; } | { name: '1906'; children: BigUnion[]; } | { name: '1907'; children: BigUnion[]; } | { name: '1908'; children: BigUnion[]; } | { name: '1909'; children: BigUnion[]; } | { name: '1910'; children: BigUnion[]; } | { name: '1911'; children: BigUnion[]; } | { name: '1912'; children: BigUnion[]; } | { name: '1913'; children: BigUnion[]; } | { name: '1914'; children: BigUnion[]; } | { name: '1915'; children: BigUnion[]; } | { name: '1916'; children: BigUnion[]; } | { name: '1917'; children: BigUnion[]; } | { name: '1918'; children: BigUnion[]; } | { name: '1919'; children: BigUnion[]; } | { name: '1920'; children: BigUnion[]; } | { name: '1921'; children: BigUnion[]; } | { name: '1922'; children: BigUnion[]; } | { name: '1923'; children: BigUnion[]; } | { name: '1924'; children: BigUnion[]; } | { name: '1925'; children: BigUnion[]; } | { name: '1926'; children: BigUnion[]; } | { name: '1927'; children: BigUnion[]; } | { name: '1928'; children: BigUnion[]; } | { name: '1929'; children: BigUnion[]; } | { name: '1930'; children: BigUnion[]; } | { name: '1931'; children: BigUnion[]; } | { name: '1932'; children: BigUnion[]; } | { name: '1933'; children: BigUnion[]; } | { name: '1934'; children: BigUnion[]; } | { name: '1935'; children: BigUnion[]; } | { name: '1936'; children: BigUnion[]; } | { name: '1937'; children: BigUnion[]; } | { name: '1938'; children: BigUnion[]; } | { name: '1939'; children: BigUnion[]; } | { name: '1940'; children: BigUnion[]; } | { name: '1941'; children: BigUnion[]; } | { name: '1942'; children: BigUnion[]; } | { name: '1943'; children: BigUnion[]; } | { name: '1944'; children: BigUnion[]; } | { name: '1945'; children: BigUnion[]; } | { name: '1946'; children: BigUnion[]; } | { name: '1947'; children: BigUnion[]; } | { name: '1948'; children: BigUnion[]; } | { name: '1949'; children: BigUnion[]; } | { name: '1950'; children: BigUnion[]; } | { name: '1951'; children: BigUnion[]; } | { name: '1952'; children: BigUnion[]; } | { name: '1953'; children: BigUnion[]; } | { name: '1954'; children: BigUnion[]; } | { name: '1955'; children: BigUnion[]; } | { name: '1956'; children: BigUnion[]; } | { name: '1957'; children: BigUnion[]; } | { name: '1958'; children: BigUnion[]; } | { name: '1959'; children: BigUnion[]; } | { name: '1960'; children: BigUnion[]; } | { name: '1961'; children: BigUnion[]; } | { name: '1962'; children: BigUnion[]; } | { name: '1963'; children: BigUnion[]; } | { name: '1964'; children: BigUnion[]; } | { name: '1965'; children: BigUnion[]; } | { name: '1966'; children: BigUnion[]; } | { name: '1967'; children: BigUnion[]; } | { name: '1968'; children: BigUnion[]; } | { name: '1969'; children: BigUnion[]; } | { name: '1970'; children: BigUnion[]; } | { name: '1971'; children: BigUnion[]; } | { name: '1972'; children: BigUnion[]; } | { name: '1973'; children: BigUnion[]; } | { name: '1974'; children: BigUnion[]; } | { name: '1975'; children: BigUnion[]; } | { name: '1976'; children: BigUnion[]; } | { name: '1977'; children: BigUnion[]; } | { name: '1978'; children: BigUnion[]; } | { name: '1979'; children: BigUnion[]; } | { name: '1980'; children: BigUnion[]; } | { name: '1981'; children: BigUnion[]; } | { name: '1982'; children: BigUnion[]; } | { name: '1983'; children: BigUnion[]; } | { name: '1984'; children: BigUnion[]; } | { name: '1985'; children: BigUnion[]; } | { name: '1986'; children: BigUnion[]; } | { name: '1987'; children: BigUnion[]; } | { name: '1988'; children: BigUnion[]; } | { name: '1989'; children: BigUnion[]; } | { name: '1990'; children: BigUnion[]; } | { name: '1991'; children: BigUnion[]; } | { name: '1992'; children: BigUnion[]; } | { name: '1993'; children: BigUnion[]; } | { name: '1994'; children: BigUnion[]; } | { name: '1995'; children: BigUnion[]; } | { name: '1996'; children: BigUnion[]; } | { name: '1997'; children: BigUnion[]; } | { name: '1998'; children: BigUnion[]; } | { name: '1999'; children: BigUnion[]; } { name: '0'; >name : "0" diff --git a/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types index 20a281417631d..c67699df0d8e9 100644 --- a/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types +++ b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types @@ -1,6 +1,6 @@ === tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts === export type ElChildren = ->ElChildren : ElChildren +>ElChildren : string | undefined | ElChildren.Void >ElChildren : any diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types index d655e3d6b040a..27b295caa8b50 100644 --- a/tests/baselines/reference/conditionalTypes1.types +++ b/tests/baselines/reference/conditionalTypes1.types @@ -1,21 +1,21 @@ === tests/cases/conformance/types/conditional/conditionalTypes1.ts === type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" ->T00 : T00 +>T00 : "b" | "d" type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" ->T01 : T01 +>T01 : "a" | "c" type T02 = Exclude void), Function>; // string | number ->T02 : T02 +>T02 : string | number type T03 = Extract void), Function>; // () => void >T03 : () => void type T04 = NonNullable; // string | number ->T04 : T04 +>T04 : string | number type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] ->T05 : T05 +>T05 : (() => string) | string[] >null : null function f1(x: T, y: NonNullable) { @@ -100,7 +100,7 @@ function f4(x: T["x"], y: NonNullableOptions : Options +>Options : { k: "a"; a: number; } | { k: "b"; b: string; } | { k: "c"; c: boolean; } >k : "a" >a : number >k : "b" @@ -113,7 +113,7 @@ type T10 = Exclude; // { k: "c", c: boolean } >k : "a" | "b" type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } ->T11 : T11 +>T11 : { k: "a"; a: number; } | { k: "b"; b: string; } >k : "a" | "b" type T12 = Exclude; // { k: "c", c: boolean } @@ -122,12 +122,12 @@ type T12 = Exclude; // { k: "c", c: boolean } >k : "b" type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } ->T13 : T13 +>T13 : { k: "a"; a: number; } | { k: "b"; b: string; } >k : "a" >k : "b" type T14 = Exclude; // Options ->T14 : T14 +>T14 : { k: "a"; a: number; } | { k: "b"; b: string; } | { k: "c"; c: boolean; } >q : "a" type T15 = Extract; // never @@ -150,13 +150,13 @@ type OptionsOfKind = Extract; >k : K type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } ->T16 : T16 +>T16 : { k: "a"; a: number; } | { k: "b"; b: string; } type Select = Extract; >Select : Select type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } ->T17 : T17 +>T17 : { k: "a"; a: number; } | { k: "b"; b: string; } type TypeName = >TypeName : TypeName @@ -169,7 +169,7 @@ type TypeName = "object"; type T20 = TypeName void)>; // "string" | "function" ->T20 : T20 +>T20 : "string" | "function" type T21 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" >T21 : "string" | "number" | "boolean" | "undefined" | "object" | "function" @@ -239,10 +239,10 @@ type NonFunctionProperties = Pick>; >NonFunctionProperties : NonFunctionProperties type T30 = FunctionProperties; ->T30 : T30 +>T30 : { updatePart: (newName: string) => void; } type T31 = NonFunctionProperties; ->T31 : T31 +>T31 : { id: number; name: string; subparts: Part[]; } function f7(x: T, y: FunctionProperties, z: NonFunctionProperties) { >f7 : (x: T, y: FunctionProperties, z: NonFunctionProperties) => void @@ -559,7 +559,7 @@ type N2 = Not; // false >true : true type N3 = Not; // boolean ->N3 : N3 +>N3 : boolean type A1 = And; // false >A1 : false @@ -590,7 +590,7 @@ type A6 = And; // false >false : false type A7 = And; // boolean ->A7 : A7 +>A7 : boolean >true : true type A8 = And; // boolean @@ -598,7 +598,7 @@ type A8 = And; // boolean >true : true type A9 = And; // boolean ->A9 : A9 +>A9 : boolean type O1 = Or; // false >O1 : false @@ -621,7 +621,7 @@ type O4 = Or; // true >true : true type O5 = Or; // boolean ->O5 : O5 +>O5 : boolean >false : false type O6 = Or; // boolean @@ -637,7 +637,7 @@ type O8 = Or; // true >true : true type O9 = Or; // boolean ->O9 : O9 +>O9 : boolean type T40 = never extends never ? true : false; // true >T40 : true @@ -977,13 +977,13 @@ type NonFooKeys2 = Exclude; >NonFooKeys2 : NonFooKeys2 type Test1 = NonFooKeys1<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz" ->Test1 : Test1 +>Test1 : "bar" | "baz" >foo : 1 >bar : 2 >baz : 3 type Test2 = NonFooKeys2<{foo: 1, bar: 2, baz: 3}>; // "bar" | "baz" ->Test2 : Test2 +>Test2 : "bar" | "baz" >foo : 1 >bar : 2 >baz : 3 @@ -997,7 +997,7 @@ interface Bar2 { bar: string; } >bar : string type FooBar = Foo2 | Bar2; ->FooBar : FooBar +>FooBar : Foo2 | Bar2 declare interface ExtractFooBar { } diff --git a/tests/baselines/reference/conditionalTypes2.types b/tests/baselines/reference/conditionalTypes2.types index d5344f98e3501..8c72188b7925e 100644 --- a/tests/baselines/reference/conditionalTypes2.types +++ b/tests/baselines/reference/conditionalTypes2.types @@ -141,11 +141,11 @@ function f12(x: string | (() => string) | undefined) { } type Foo = { foo: string }; ->Foo : Foo +>Foo : { foo: string; } >foo : string type Bar = { bar: string }; ->Bar : Bar +>Bar : { bar: string; } >bar : string declare function fooBar(x: { foo: string, bar: string }): void; @@ -369,7 +369,7 @@ type T3 = MaybeTrue<{ b: boolean }>; // "yes" // Repro from #28824 type Union = 'a' | 'b'; ->Union : Union +>Union : "b" | "a" type Product = { f1: A, f2: B}; >Product : Product @@ -377,11 +377,11 @@ type Product = { f1: A, f2: B}; >f2 : B type ProductUnion = Product<'a', 0> | Product<'b', 1>; ->ProductUnion : ProductUnion +>ProductUnion : Product<"a", 0> | Product<"b", 1> // {a: "b"; b: "a"} type UnionComplement = { ->UnionComplement : UnionComplement +>UnionComplement : { b: "a"; a: "b"; } [K in Union]: Exclude }; @@ -393,7 +393,7 @@ type UCB = UnionComplement['b']; // {a: "a"; b: "b"} type UnionComplementComplement = { ->UnionComplementComplement : UnionComplementComplement +>UnionComplementComplement : { b: "b"; a: "a"; } [K in Union]: Exclude> }; @@ -405,7 +405,7 @@ type UCCB = UnionComplementComplement['b']; // {a: Product<'b', 1>; b: Product<'a', 0>} type ProductComplement = { ->ProductComplement : ProductComplement +>ProductComplement : { b: Product<"a", 0>; a: Product<"b", 1>; } [K in Union]: Exclude >f1 : K @@ -419,7 +419,7 @@ type PCB = ProductComplement['b']; // {a: Product<'a', 0>; b: Product<'b', 1>} type ProductComplementComplement = { ->ProductComplementComplement : ProductComplementComplement +>ProductComplementComplement : { b: Product<"b", 1>; a: Product<"a", 0>; } [K in Union]: Exclude> >f1 : K diff --git a/tests/baselines/reference/constAssertions.types b/tests/baselines/reference/constAssertions.types index 476c197cfb9bc..e764b8c6c3007 100644 --- a/tests/baselines/reference/constAssertions.types +++ b/tests/baselines/reference/constAssertions.types @@ -453,10 +453,10 @@ function ff3(x: 'foo' | 'bar', y: object) { } type Action = "verify" | "write"; ->Action : Action +>Action : "verify" | "write" type ContentMatch = "match" | "nonMatch"; ->ContentMatch : ContentMatch +>ContentMatch : "match" | "nonMatch" type Outcome = `${Action}_${ContentMatch}`; >Outcome : "verify_match" | "verify_nonMatch" | "write_match" | "write_nonMatch" diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types index 1170aa71c4827..b3f5a0e9f91b0 100644 --- a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types @@ -6,7 +6,7 @@ interface Map { } export type ImmutableTypes = IImmutableMap; ->ImmutableTypes : ImmutableTypes +>ImmutableTypes : IImmutableMap export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; >ImmutableModel : ImmutableModel @@ -19,7 +19,7 @@ export interface IImmutableMap> extends Map; ->ImmutableTypes2 : ImmutableTypes2 +>ImmutableTypes2 : IImmutableMap2 type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; >isImmutableType : isImmutableType diff --git a/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.js b/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.js new file mode 100644 index 0000000000000..9d2e2e71697d2 --- /dev/null +++ b/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.js @@ -0,0 +1,72 @@ +//// [constructorWithParameterPropertiesAndPrivateFields.es2015.ts] +// https://github.com/microsoft/TypeScript/issues/48771 + +class A { + readonly #privateField: string; + + constructor(arg: { key: string }, public exposedField: number) { + ({ key: this.#privateField } = arg); + } + + log() { + console.log(this.#privateField); + console.log(this.exposedField); + } +} + +class B { + readonly #privateField: string; + + constructor(arg: { key: string }, public exposedField: number) { + "prologue"; + ({ key: this.#privateField } = arg); + } + + log() { + console.log(this.#privateField); + console.log(this.exposedField); + } +} + + +//// [constructorWithParameterPropertiesAndPrivateFields.es2015.js] +// https://github.com/microsoft/TypeScript/issues/48771 +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _A_privateField, _B_privateField; +class A { + constructor(arg, exposedField) { + var _a; + this.exposedField = exposedField; + _A_privateField.set(this, void 0); + (_a = this, { key: ({ set value(_b) { __classPrivateFieldSet(_a, _A_privateField, _b, "f"); } }).value } = arg); + } + log() { + console.log(__classPrivateFieldGet(this, _A_privateField, "f")); + console.log(this.exposedField); + } +} +_A_privateField = new WeakMap(); +class B { + constructor(arg, exposedField) { + "prologue"; + var _a; + this.exposedField = exposedField; + _B_privateField.set(this, void 0); + (_a = this, { key: ({ set value(_b) { __classPrivateFieldSet(_a, _B_privateField, _b, "f"); } }).value } = arg); + } + log() { + console.log(__classPrivateFieldGet(this, _B_privateField, "f")); + console.log(this.exposedField); + } +} +_B_privateField = new WeakMap(); diff --git a/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.symbols b/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.symbols new file mode 100644 index 0000000000000..cffef43438aac --- /dev/null +++ b/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.symbols @@ -0,0 +1,80 @@ +=== tests/cases/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.ts === +// https://github.com/microsoft/TypeScript/issues/48771 + +class A { +>A : Symbol(A, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 0, 0)) + + readonly #privateField: string; +>#privateField : Symbol(A.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 2, 9)) + + constructor(arg: { key: string }, public exposedField: number) { +>arg : Symbol(arg, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 5, 14)) +>key : Symbol(key, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 5, 20)) +>exposedField : Symbol(A.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 5, 35)) + + ({ key: this.#privateField } = arg); +>key : Symbol(key, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 6, 6)) +>this.#privateField : Symbol(A.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 2, 9)) +>this : Symbol(A, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 0, 0)) +>arg : Symbol(arg, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 5, 14)) + } + + log() { +>log : Symbol(A.log, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 7, 3)) + + console.log(this.#privateField); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>this.#privateField : Symbol(A.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 2, 9)) +>this : Symbol(A, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 0, 0)) + + console.log(this.exposedField); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>this.exposedField : Symbol(A.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 5, 35)) +>this : Symbol(A, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 0, 0)) +>exposedField : Symbol(A.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 5, 35)) + } +} + +class B { +>B : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1)) + + readonly #privateField: string; +>#privateField : Symbol(B.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 15, 9)) + + constructor(arg: { key: string }, public exposedField: number) { +>arg : Symbol(arg, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 14)) +>key : Symbol(key, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 20)) +>exposedField : Symbol(B.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 35)) + + "prologue"; + ({ key: this.#privateField } = arg); +>key : Symbol(key, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 20, 6)) +>this.#privateField : Symbol(B.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 15, 9)) +>this : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1)) +>arg : Symbol(arg, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 14)) + } + + log() { +>log : Symbol(B.log, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 21, 3)) + + console.log(this.#privateField); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>this.#privateField : Symbol(B.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 15, 9)) +>this : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1)) + + console.log(this.exposedField); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>this.exposedField : Symbol(B.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 35)) +>this : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1)) +>exposedField : Symbol(B.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 35)) + } +} + diff --git a/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.types b/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.types new file mode 100644 index 0000000000000..ea034c2b054b5 --- /dev/null +++ b/tests/baselines/reference/constructorWithParameterPropertiesAndPrivateFields.es2015.types @@ -0,0 +1,92 @@ +=== tests/cases/compiler/constructorWithParameterPropertiesAndPrivateFields.es2015.ts === +// https://github.com/microsoft/TypeScript/issues/48771 + +class A { +>A : A + + readonly #privateField: string; +>#privateField : string + + constructor(arg: { key: string }, public exposedField: number) { +>arg : { key: string; } +>key : string +>exposedField : number + + ({ key: this.#privateField } = arg); +>({ key: this.#privateField } = arg) : { key: string; } +>{ key: this.#privateField } = arg : { key: string; } +>{ key: this.#privateField } : { key: string; } +>key : string +>this.#privateField : string +>this : this +>arg : { key: string; } + } + + log() { +>log : () => void + + console.log(this.#privateField); +>console.log(this.#privateField) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>this.#privateField : string +>this : this + + console.log(this.exposedField); +>console.log(this.exposedField) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>this.exposedField : number +>this : this +>exposedField : number + } +} + +class B { +>B : B + + readonly #privateField: string; +>#privateField : string + + constructor(arg: { key: string }, public exposedField: number) { +>arg : { key: string; } +>key : string +>exposedField : number + + "prologue"; +>"prologue" : "prologue" + + ({ key: this.#privateField } = arg); +>({ key: this.#privateField } = arg) : { key: string; } +>{ key: this.#privateField } = arg : { key: string; } +>{ key: this.#privateField } : { key: string; } +>key : string +>this.#privateField : string +>this : this +>arg : { key: string; } + } + + log() { +>log : () => void + + console.log(this.#privateField); +>console.log(this.#privateField) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>this.#privateField : string +>this : this + + console.log(this.exposedField); +>console.log(this.exposedField) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>this.exposedField : number +>this : this +>exposedField : number + } +} + diff --git a/tests/baselines/reference/constructorWithSuperAndPrologue.es5.js b/tests/baselines/reference/constructorWithSuperAndPrologue.es5.js new file mode 100644 index 0000000000000..a06a4f7a4faa7 --- /dev/null +++ b/tests/baselines/reference/constructorWithSuperAndPrologue.es5.js @@ -0,0 +1,52 @@ +//// [constructorWithSuperAndPrologue.es5.ts] +// https://github.com/microsoft/TypeScript/issues/48761 +"use strict"; + +class A { + public constructor() { + console.log("A") + } +} + +class B extends A { + constructor() { + "ngInject"; + console.log("B") + super(); + } +} + + +//// [constructorWithSuperAndPrologue.es5.js] +// https://github.com/microsoft/TypeScript/issues/48761 +"use strict"; +var __extends = (this && this.__extends) || (function () { + 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + console.log("A"); + } + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + "ngInject"; + console.log("B"); + return _super.call(this) || this; + } + return B; +}(A)); diff --git a/tests/baselines/reference/constructorWithSuperAndPrologue.es5.symbols b/tests/baselines/reference/constructorWithSuperAndPrologue.es5.symbols new file mode 100644 index 0000000000000..4ec2815f8a485 --- /dev/null +++ b/tests/baselines/reference/constructorWithSuperAndPrologue.es5.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/constructorWithSuperAndPrologue.es5.ts === +// https://github.com/microsoft/TypeScript/issues/48761 +"use strict"; + +class A { +>A : Symbol(A, Decl(constructorWithSuperAndPrologue.es5.ts, 1, 13)) + + public constructor() { + console.log("A") +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + } +} + +class B extends A { +>B : Symbol(B, Decl(constructorWithSuperAndPrologue.es5.ts, 7, 1)) +>A : Symbol(A, Decl(constructorWithSuperAndPrologue.es5.ts, 1, 13)) + + constructor() { + "ngInject"; + console.log("B") +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + + super(); +>super : Symbol(A, Decl(constructorWithSuperAndPrologue.es5.ts, 1, 13)) + } +} + diff --git a/tests/baselines/reference/constructorWithSuperAndPrologue.es5.types b/tests/baselines/reference/constructorWithSuperAndPrologue.es5.types new file mode 100644 index 0000000000000..7e615a1a6601c --- /dev/null +++ b/tests/baselines/reference/constructorWithSuperAndPrologue.es5.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/constructorWithSuperAndPrologue.es5.ts === +// https://github.com/microsoft/TypeScript/issues/48761 +"use strict"; +>"use strict" : "use strict" + +class A { +>A : A + + public constructor() { + console.log("A") +>console.log("A") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"A" : "A" + } +} + +class B extends A { +>B : B +>A : A + + constructor() { + "ngInject"; +>"ngInject" : "ngInject" + + console.log("B") +>console.log("B") : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>"B" : "B" + + super(); +>super() : void +>super : typeof A + } +} + diff --git a/tests/baselines/reference/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.types b/tests/baselines/reference/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.types index c9a236a44ef10..e561a05bc89b5 100644 --- a/tests/baselines/reference/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.types +++ b/tests/baselines/reference/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.types @@ -1,7 +1,7 @@ === tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts === // must target esnext for `String.normalize` to exist type Validate = (text: string, pos: number, self: Rule) => number | boolean; ->Validate : Validate +>Validate : (text: string, pos: number, self: Rule) => number | boolean >text : string >pos : number >self : Rule @@ -17,7 +17,7 @@ interface FullRule { } type Rule = string | FullRule; ->Rule : Rule +>Rule : string | FullRule const obj: {field: Rule} = { >obj : { field: Rule; } diff --git a/tests/baselines/reference/contextualTypeOfIndexedAccessParameter.types b/tests/baselines/reference/contextualTypeOfIndexedAccessParameter.types index c72f7b139912a..5baf2f4a62a49 100644 --- a/tests/baselines/reference/contextualTypeOfIndexedAccessParameter.types +++ b/tests/baselines/reference/contextualTypeOfIndexedAccessParameter.types @@ -1,9 +1,9 @@ === tests/cases/compiler/contextualTypeOfIndexedAccessParameter.ts === type Keys = "a" | "b"; ->Keys : Keys +>Keys : "a" | "b" type OptionsForKey = { a: { cb: (p: number) => number } } & { b: {} }; ->OptionsForKey : OptionsForKey +>OptionsForKey : { a: { cb: (p: number) => number; }; } & { b: {}; } >a : { cb: (p: number) => number; } >cb : (p: number) => number >p : number diff --git a/tests/baselines/reference/contextualTypeShouldBeLiteral.types b/tests/baselines/reference/contextualTypeShouldBeLiteral.types index d9795c7e33f7c..56f5b3c363e8a 100644 --- a/tests/baselines/reference/contextualTypeShouldBeLiteral.types +++ b/tests/baselines/reference/contextualTypeShouldBeLiteral.types @@ -243,7 +243,7 @@ interface TestString { } type TestGeneric = (TestString | TestObject) & { [k: string]: any; }; ->TestGeneric : TestGeneric +>TestGeneric : (TestObject | TestString) & { [k: string]: any; } >k : string const test: TestGeneric = { diff --git a/tests/baselines/reference/contextualTypingArrayDestructuringWithDefaults.types b/tests/baselines/reference/contextualTypingArrayDestructuringWithDefaults.types index 30e35d683dbd3..5425ab030b62c 100644 --- a/tests/baselines/reference/contextualTypingArrayDestructuringWithDefaults.types +++ b/tests/baselines/reference/contextualTypingArrayDestructuringWithDefaults.types @@ -1,6 +1,6 @@ === tests/cases/compiler/contextualTypingArrayDestructuringWithDefaults.ts === type I = { a: "a" }; ->I : I +>I : { a: "a"; } >a : "a" let [ c0 = {a: "a"} ]: [I?] = []; diff --git a/tests/baselines/reference/contextualTypingOfTooShortOverloads.types b/tests/baselines/reference/contextualTypingOfTooShortOverloads.types index 621bc0751793f..ede485d8360ab 100644 --- a/tests/baselines/reference/contextualTypingOfTooShortOverloads.types +++ b/tests/baselines/reference/contextualTypingOfTooShortOverloads.types @@ -60,10 +60,10 @@ interface IRouterMatcher { } type PathParams = string | RegExp | (string | RegExp)[]; ->PathParams : PathParams +>PathParams : string | RegExp | (string | RegExp)[] type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[]; ->RequestHandlerParams : RequestHandlerParams +>RequestHandlerParams : RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[] interface RequestHandler { (req: Request, res: Response, next: NextFunction): any; diff --git a/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types b/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types index f67d3948b0003..b3fde6f144846 100644 --- a/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types +++ b/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types @@ -1,6 +1,6 @@ === tests/cases/compiler/contextuallyTypedByDiscriminableUnion.ts === type ADT = { ->ADT : ADT +>ADT : { kind: "a"; method(x: string): number; } | { kind: "b"; method(x: number): string; } kind: "a", >kind : "a" diff --git a/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types b/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types index db65878b320d3..e39e3bde4d733 100644 --- a/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types +++ b/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types @@ -21,7 +21,7 @@ declare function id4 any>(input: T): T; >input : T declare function id5 any>(input: T): T; ->id5 : any>(input: T) => T +>id5 : any>(input: T) => T >x : number | undefined >input : T diff --git a/tests/baselines/reference/contextuallyTypedSymbolNamedProperties.types b/tests/baselines/reference/contextuallyTypedSymbolNamedProperties.types index 7f3da21666af0..508845c83f6c4 100644 --- a/tests/baselines/reference/contextuallyTypedSymbolNamedProperties.types +++ b/tests/baselines/reference/contextuallyTypedSymbolNamedProperties.types @@ -14,7 +14,7 @@ const B = Symbol("B"); >"B" : "B" type Action = ->Action : Action +>Action : { type: typeof A; data: string; } | { type: typeof B; data: number; } | {type: typeof A, data: string} >type : unique symbol diff --git a/tests/baselines/reference/controlFlowAliasing.types b/tests/baselines/reference/controlFlowAliasing.types index a3c7f9f7f4f19..1f97602b3f290 100644 --- a/tests/baselines/reference/controlFlowAliasing.types +++ b/tests/baselines/reference/controlFlowAliasing.types @@ -532,7 +532,7 @@ function f27(outer: { obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: nu } function f28(obj?: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) { ->f28 : (obj?: { kind: 'foo'; foo: string; } | { kind: 'bar'; bar: number; } | undefined) => void +>f28 : (obj?: { kind: 'foo'; foo: string;} | { kind: 'bar'; bar: number;}) => void >obj : { kind: 'foo'; foo: string; } | { kind: 'bar'; bar: number; } | undefined >kind : "foo" >foo : string @@ -844,7 +844,7 @@ function f40(obj: { kind: 'foo', foo?: string } | { kind: 'bar', bar?: number }) // Unsupported narrowing of destructured payload by destructured discriminant type Data = { kind: 'str', payload: string } | { kind: 'num', payload: number }; ->Data : Data +>Data : { kind: 'str'; payload: string; } | { kind: 'num'; payload: number; } >kind : "str" >payload : string >kind : "num" diff --git a/tests/baselines/reference/controlFlowAssignmentExpression.types b/tests/baselines/reference/controlFlowAssignmentExpression.types index d56aee7c76727..8724a73fd8d9c 100644 --- a/tests/baselines/reference/controlFlowAssignmentExpression.types +++ b/tests/baselines/reference/controlFlowAssignmentExpression.types @@ -47,7 +47,7 @@ x; // number // https://github.com/microsoft/TypeScript/issues/35484 type D = { done: true, value: 1 } | { done: false, value: 2 }; ->D : D +>D : { done: true; value: 1; } | { done: false; value: 2; } >done : true >true : true >value : 1 diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index 8e43d38765357..9c188295a82f0 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -54,7 +54,7 @@ declare function isHTMLCollection(sourceObj: any): sourceObj is HTMLCollection; >sourceObj : any type EventTargetLike = {a: string} | HTMLCollection | NodeList; ->EventTargetLike : EventTargetLike +>EventTargetLike : NodeList | HTMLCollection | { a: string; } >a : string var sourceObj: EventTargetLike = undefined; diff --git a/tests/baselines/reference/controlFlowDestructuringLoop.types b/tests/baselines/reference/controlFlowDestructuringLoop.types index a4735399f9e4a..c0b86606c0f96 100644 --- a/tests/baselines/reference/controlFlowDestructuringLoop.types +++ b/tests/baselines/reference/controlFlowDestructuringLoop.types @@ -8,7 +8,7 @@ interface StrVal { val: string; } >val : string type Val = NumVal | StrVal; ->Val : Val +>Val : NumVal | StrVal function isNumVal(x: Val): x is NumVal { >isNumVal : (x: Val) => x is NumVal diff --git a/tests/baselines/reference/controlFlowForCatchAndFinally.types b/tests/baselines/reference/controlFlowForCatchAndFinally.types index c159655a0a816..450aa2d595d54 100644 --- a/tests/baselines/reference/controlFlowForCatchAndFinally.types +++ b/tests/baselines/reference/controlFlowForCatchAndFinally.types @@ -1,11 +1,11 @@ === tests/cases/compiler/controlFlowForCatchAndFinally.ts === type Page = {close(): Promise; content(): Promise}; ->Page : Page +>Page : { close(): Promise; content(): Promise; } >close : () => Promise >content : () => Promise type Browser = {close(): Promise}; ->Browser : Browser +>Browser : { close(): Promise; } >close : () => Promise declare function test1(): Promise; diff --git a/tests/baselines/reference/controlFlowForInStatement2.types b/tests/baselines/reference/controlFlowForInStatement2.types index 2705b8b7d51ed..bf69cfe70a0dd 100644 --- a/tests/baselines/reference/controlFlowForInStatement2.types +++ b/tests/baselines/reference/controlFlowForInStatement2.types @@ -8,12 +8,12 @@ const keywordB = 'b'; >'b' : "b" type A = { [keywordA]: number }; ->A : A +>A : { a: number; } >[keywordA] : number >keywordA : "a" type B = { [keywordB]: string }; ->B : B +>B : { b: string; } >[keywordB] : string >keywordB : "b" diff --git a/tests/baselines/reference/controlFlowForIndexSignatures.errors.txt b/tests/baselines/reference/controlFlowForIndexSignatures.errors.txt new file mode 100644 index 0000000000000..aedc120c1c932 --- /dev/null +++ b/tests/baselines/reference/controlFlowForIndexSignatures.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/controlFlowForIndexSignatures.ts(20,23): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/compiler/controlFlowForIndexSignatures.ts (1 errors) ==== + type Foo = { bar: string }; + const boo: Foo = { bar: 'bar' }; + + function a(aboo1?: Foo) { + if (!aboo1) return; + const aboo2: { [key: string]: typeof aboo1.bar } = boo; + } + + declare let b: Foo | undefined; + if (b) { + const bboo: { [key: string]: typeof b.bar } = boo; + } + b = boo; + const bboo: { [key: string]: typeof b.bar } = boo; + + declare let c: string | number; + if (typeof c === 'string') { + type C = { [key: string]: typeof c }; + const boo1: C = { bar: 'works' }; + const boo2: C = { bar: 1 }; // should error + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6501 tests/cases/compiler/controlFlowForIndexSignatures.ts:18:16: The expected type comes from this index signature. + } + \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowForIndexSignatures.js b/tests/baselines/reference/controlFlowForIndexSignatures.js new file mode 100644 index 0000000000000..c63ff537d0016 --- /dev/null +++ b/tests/baselines/reference/controlFlowForIndexSignatures.js @@ -0,0 +1,40 @@ +//// [controlFlowForIndexSignatures.ts] +type Foo = { bar: string }; +const boo: Foo = { bar: 'bar' }; + +function a(aboo1?: Foo) { + if (!aboo1) return; + const aboo2: { [key: string]: typeof aboo1.bar } = boo; +} + +declare let b: Foo | undefined; +if (b) { + const bboo: { [key: string]: typeof b.bar } = boo; +} +b = boo; +const bboo: { [key: string]: typeof b.bar } = boo; + +declare let c: string | number; +if (typeof c === 'string') { + type C = { [key: string]: typeof c }; + const boo1: C = { bar: 'works' }; + const boo2: C = { bar: 1 }; // should error +} + + +//// [controlFlowForIndexSignatures.js] +var boo = { bar: 'bar' }; +function a(aboo1) { + if (!aboo1) + return; + var aboo2 = boo; +} +if (b) { + var bboo_1 = boo; +} +b = boo; +var bboo = boo; +if (typeof c === 'string') { + var boo1 = { bar: 'works' }; + var boo2 = { bar: 1 }; // should error +} diff --git a/tests/baselines/reference/controlFlowForIndexSignatures.symbols b/tests/baselines/reference/controlFlowForIndexSignatures.symbols new file mode 100644 index 0000000000000..f2b71e58f080d --- /dev/null +++ b/tests/baselines/reference/controlFlowForIndexSignatures.symbols @@ -0,0 +1,76 @@ +=== tests/cases/compiler/controlFlowForIndexSignatures.ts === +type Foo = { bar: string }; +>Foo : Symbol(Foo, Decl(controlFlowForIndexSignatures.ts, 0, 0)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) + +const boo: Foo = { bar: 'bar' }; +>boo : Symbol(boo, Decl(controlFlowForIndexSignatures.ts, 1, 5)) +>Foo : Symbol(Foo, Decl(controlFlowForIndexSignatures.ts, 0, 0)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 1, 18)) + +function a(aboo1?: Foo) { +>a : Symbol(a, Decl(controlFlowForIndexSignatures.ts, 1, 32)) +>aboo1 : Symbol(aboo1, Decl(controlFlowForIndexSignatures.ts, 3, 11)) +>Foo : Symbol(Foo, Decl(controlFlowForIndexSignatures.ts, 0, 0)) + + if (!aboo1) return; +>aboo1 : Symbol(aboo1, Decl(controlFlowForIndexSignatures.ts, 3, 11)) + + const aboo2: { [key: string]: typeof aboo1.bar } = boo; +>aboo2 : Symbol(aboo2, Decl(controlFlowForIndexSignatures.ts, 5, 9)) +>key : Symbol(key, Decl(controlFlowForIndexSignatures.ts, 5, 20)) +>aboo1.bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) +>aboo1 : Symbol(aboo1, Decl(controlFlowForIndexSignatures.ts, 3, 11)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) +>boo : Symbol(boo, Decl(controlFlowForIndexSignatures.ts, 1, 5)) +} + +declare let b: Foo | undefined; +>b : Symbol(b, Decl(controlFlowForIndexSignatures.ts, 8, 11)) +>Foo : Symbol(Foo, Decl(controlFlowForIndexSignatures.ts, 0, 0)) + +if (b) { +>b : Symbol(b, Decl(controlFlowForIndexSignatures.ts, 8, 11)) + + const bboo: { [key: string]: typeof b.bar } = boo; +>bboo : Symbol(bboo, Decl(controlFlowForIndexSignatures.ts, 10, 9)) +>key : Symbol(key, Decl(controlFlowForIndexSignatures.ts, 10, 19)) +>b.bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) +>b : Symbol(b, Decl(controlFlowForIndexSignatures.ts, 8, 11)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) +>boo : Symbol(boo, Decl(controlFlowForIndexSignatures.ts, 1, 5)) +} +b = boo; +>b : Symbol(b, Decl(controlFlowForIndexSignatures.ts, 8, 11)) +>boo : Symbol(boo, Decl(controlFlowForIndexSignatures.ts, 1, 5)) + +const bboo: { [key: string]: typeof b.bar } = boo; +>bboo : Symbol(bboo, Decl(controlFlowForIndexSignatures.ts, 13, 5)) +>key : Symbol(key, Decl(controlFlowForIndexSignatures.ts, 13, 15)) +>b.bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) +>b : Symbol(b, Decl(controlFlowForIndexSignatures.ts, 8, 11)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 0, 12)) +>boo : Symbol(boo, Decl(controlFlowForIndexSignatures.ts, 1, 5)) + +declare let c: string | number; +>c : Symbol(c, Decl(controlFlowForIndexSignatures.ts, 15, 11)) + +if (typeof c === 'string') { +>c : Symbol(c, Decl(controlFlowForIndexSignatures.ts, 15, 11)) + + type C = { [key: string]: typeof c }; +>C : Symbol(C, Decl(controlFlowForIndexSignatures.ts, 16, 28)) +>key : Symbol(key, Decl(controlFlowForIndexSignatures.ts, 17, 16)) +>c : Symbol(c, Decl(controlFlowForIndexSignatures.ts, 15, 11)) + + const boo1: C = { bar: 'works' }; +>boo1 : Symbol(boo1, Decl(controlFlowForIndexSignatures.ts, 18, 9)) +>C : Symbol(C, Decl(controlFlowForIndexSignatures.ts, 16, 28)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 18, 21)) + + const boo2: C = { bar: 1 }; // should error +>boo2 : Symbol(boo2, Decl(controlFlowForIndexSignatures.ts, 19, 9)) +>C : Symbol(C, Decl(controlFlowForIndexSignatures.ts, 16, 28)) +>bar : Symbol(bar, Decl(controlFlowForIndexSignatures.ts, 19, 21)) +} + diff --git a/tests/baselines/reference/controlFlowForIndexSignatures.types b/tests/baselines/reference/controlFlowForIndexSignatures.types new file mode 100644 index 0000000000000..20fff99f2c158 --- /dev/null +++ b/tests/baselines/reference/controlFlowForIndexSignatures.types @@ -0,0 +1,82 @@ +=== tests/cases/compiler/controlFlowForIndexSignatures.ts === +type Foo = { bar: string }; +>Foo : { bar: string; } +>bar : string + +const boo: Foo = { bar: 'bar' }; +>boo : Foo +>{ bar: 'bar' } : { bar: string; } +>bar : string +>'bar' : "bar" + +function a(aboo1?: Foo) { +>a : (aboo1?: Foo) => void +>aboo1 : Foo | undefined + + if (!aboo1) return; +>!aboo1 : boolean +>aboo1 : Foo | undefined + + const aboo2: { [key: string]: typeof aboo1.bar } = boo; +>aboo2 : { [key: string]: string; } +>key : string +>aboo1.bar : string +>aboo1 : Foo +>bar : string +>boo : Foo +} + +declare let b: Foo | undefined; +>b : Foo | undefined + +if (b) { +>b : Foo | undefined + + const bboo: { [key: string]: typeof b.bar } = boo; +>bboo : { [key: string]: string; } +>key : string +>b.bar : string +>b : Foo +>bar : string +>boo : Foo +} +b = boo; +>b = boo : Foo +>b : Foo | undefined +>boo : Foo + +const bboo: { [key: string]: typeof b.bar } = boo; +>bboo : { [key: string]: string; } +>key : string +>b.bar : string +>b : Foo +>bar : string +>boo : Foo + +declare let c: string | number; +>c : string | number + +if (typeof c === 'string') { +>typeof c === 'string' : boolean +>typeof c : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>c : string | number +>'string' : "string" + + type C = { [key: string]: typeof c }; +>C : { [key: string]: string; } +>key : string +>c : string + + const boo1: C = { bar: 'works' }; +>boo1 : { [key: string]: string; } +>{ bar: 'works' } : { bar: string; } +>bar : string +>'works' : "works" + + const boo2: C = { bar: 1 }; // should error +>boo2 : { [key: string]: string; } +>{ bar: 1 } : { bar: number; } +>bar : number +>1 : 1 +} + diff --git a/tests/baselines/reference/controlFlowGenericTypes.types b/tests/baselines/reference/controlFlowGenericTypes.types index 6ee07abf4d63c..fc502a7dede82 100644 --- a/tests/baselines/reference/controlFlowGenericTypes.types +++ b/tests/baselines/reference/controlFlowGenericTypes.types @@ -196,22 +196,22 @@ export function bounceAndTakeIfA(value: AB): AB { // Repro from #13995 type Common = { id: number }; ->Common : Common +>Common : { id: number; } >id : number type AA = { tag: 'A', id: number }; ->AA : AA +>AA : { tag: 'A'; id: number; } >tag : "A" >id : number type BB = { tag: 'B', id: number, foo: number }; ->BB : BB +>BB : { tag: 'B'; id: number; foo: number; } >tag : "B" >id : number >foo : number type MyUnion = AA | BB; ->MyUnion : MyUnion +>MyUnion : AA | BB const fn = (value: MyUnion) => { >fn : (value: MyUnion) => void @@ -284,7 +284,7 @@ const fn2 = (value: T): MyUnion => { // Repro from #13995 type A1 = { ->A1 : A1 +>A1 : { testable: true; doTest: () => void; } testable: true >testable : true @@ -294,7 +294,7 @@ type A1 = { >doTest : () => void } type B1 = { ->B1 : B1 +>B1 : { testable: false; } testable: false >testable : false @@ -303,7 +303,7 @@ type B1 = { }; type Union = A1 | B1 ->Union : Union +>Union : A1 | B1 function notWorking(object: T) { >notWorking : (object: T) => void @@ -561,7 +561,7 @@ interface Checkbox { } type Control = Button | Checkbox; ->Control : Control +>Control : Button | Checkbox function update(control : T | undefined, key: K, value: T[K]): void { >update : (control: T | undefined, key: K, value: T[K]) => void diff --git a/tests/baselines/reference/controlFlowInOperator.types b/tests/baselines/reference/controlFlowInOperator.types index cae50e4052f8e..fb1c3f8ccc044 100644 --- a/tests/baselines/reference/controlFlowInOperator.types +++ b/tests/baselines/reference/controlFlowInOperator.types @@ -12,12 +12,12 @@ const d = 'd'; >'d' : "d" type A = { [a]: number; }; ->A : A +>A : { a: number; } >[a] : number >a : "a" type B = { [b]: string; }; ->B : B +>B : { b: string; } >[b] : string >b : "b" diff --git a/tests/baselines/reference/controlFlowOptionalChain.types b/tests/baselines/reference/controlFlowOptionalChain.types index 4e335fca6d287..8eb843fb0600b 100644 --- a/tests/baselines/reference/controlFlowOptionalChain.types +++ b/tests/baselines/reference/controlFlowOptionalChain.types @@ -635,7 +635,7 @@ function f01(x: unknown) { } type Thing = { foo: string | number, bar(): number, baz: object }; ->Thing : Thing +>Thing : { foo: string | number; bar(): number; baz: object; } >foo : string | number >bar : () => number >baz : object @@ -1870,7 +1870,7 @@ function f41(o: Thing | undefined) { // Repros from #34570 type Shape = ->Shape : Shape +>Shape : { type: 'rectangle'; width: number; height: number; } | { type: 'circle'; radius: number; } | { type: 'rectangle', width: number, height: number } >type : "rectangle" @@ -1882,7 +1882,7 @@ type Shape = >radius : number function getArea(shape?: Shape) { ->getArea : (shape?: Shape | undefined) => number +>getArea : (shape?: Shape) => number >shape : Shape | undefined switch (shape?.type) { @@ -1923,7 +1923,7 @@ function getArea(shape?: Shape) { } type Feature = { ->Feature : Feature +>Feature : { id: string; geometry?: { type: string; coordinates: number[]; } | undefined; } id: string; >id : string diff --git a/tests/baselines/reference/controlFlowOptionalChain2.types b/tests/baselines/reference/controlFlowOptionalChain2.types index f3b2d1cd573d9..c2857e8761637 100644 --- a/tests/baselines/reference/controlFlowOptionalChain2.types +++ b/tests/baselines/reference/controlFlowOptionalChain2.types @@ -1,6 +1,6 @@ === tests/cases/conformance/controlFlow/controlFlowOptionalChain2.ts === type A = { ->A : A +>A : { type: 'A'; name: string; } type: 'A'; >type : "A" @@ -10,7 +10,7 @@ type A = { } type B = { ->B : B +>B : { type: 'B'; } type: 'B'; >type : "B" @@ -70,18 +70,18 @@ function funcThree(arg: A | B | null) { } type U = { kind: undefined, u: 'u' } ->U : U +>U : { kind: undefined; u: 'u'; } >kind : undefined >u : "u" type N = { kind: null, n: 'n' } ->N : N +>N : { kind: null; n: 'n'; } >kind : null >null : null >n : "n" type X = { kind: 'X', x: 'x' } ->X : X +>X : { kind: 'X'; x: 'x'; } >kind : "X" >x : "x" diff --git a/tests/baselines/reference/controlFlowStringIndex.types b/tests/baselines/reference/controlFlowStringIndex.types index 521db65b4af69..4baba673c7e12 100644 --- a/tests/baselines/reference/controlFlowStringIndex.types +++ b/tests/baselines/reference/controlFlowStringIndex.types @@ -1,6 +1,6 @@ === tests/cases/conformance/controlFlow/controlFlowStringIndex.ts === type A = { ->A : A +>A : { [index: string]: number | null; other: number | null; } other: number | null; >other : number | null diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences3.errors.txt b/tests/baselines/reference/correctlyMarkAliasAsReferences3.errors.txt new file mode 100644 index 0000000000000..080d37c28cb37 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences3.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/jsx/0.tsx(6,21): error TS2698: Spread types may only be created from object types. + + +==== tests/cases/conformance/jsx/0.tsx (1 errors) ==== + /// + import * as cx from 'classnames'; + import * as React from "react"; + + let buttonProps; + let k = ; + +==== tests/cases/conformance/jsx/declaration.d.ts (0 errors) ==== + declare module "classnames"; + \ No newline at end of file diff --git a/tests/baselines/reference/correlatedUnions.types b/tests/baselines/reference/correlatedUnions.types index ec83dd5426dfa..6d2074195b17c 100644 --- a/tests/baselines/reference/correlatedUnions.types +++ b/tests/baselines/reference/correlatedUnions.types @@ -2,7 +2,7 @@ // Various repros from #30581 type RecordMap = { n: number, s: string, b: boolean }; ->RecordMap : RecordMap +>RecordMap : { n: number; s: string; b: boolean; } >n : number >s : string >b : boolean @@ -71,16 +71,16 @@ processRecord({ kind: 'n', v: 42, f: v => v.toExponential() }); // -------- type TextFieldData = { value: string } ->TextFieldData : TextFieldData +>TextFieldData : { value: string; } >value : string type SelectFieldData = { options: string[], selectedValue: string } ->SelectFieldData : SelectFieldData +>SelectFieldData : { options: string[]; selectedValue: string; } >options : string[] >selectedValue : string type FieldMap = { ->FieldMap : FieldMap +>FieldMap : { text: TextFieldData; select: SelectFieldData; } text: TextFieldData; >text : TextFieldData @@ -99,7 +99,7 @@ type RenderFunc = (props: FieldMap[K]) => void; >props : FieldMap[K] type RenderFuncMap = { [K in keyof FieldMap]: RenderFunc }; ->RenderFuncMap : RenderFuncMap +>RenderFuncMap : { text: RenderFunc<"text">; select: RenderFunc<"select">; } function renderTextField(props: TextFieldData) {} >renderTextField : (props: TextFieldData) => void @@ -146,7 +146,7 @@ function renderField(field: FormField) { // -------- type TypeMap = { ->TypeMap : TypeMap +>TypeMap : { foo: string; bar: number; } foo: string, >foo : string @@ -160,7 +160,7 @@ type Keys = keyof TypeMap; >Keys : keyof TypeMap type HandlerMap = { [P in Keys]: (x: TypeMap[P]) => void }; ->HandlerMap : HandlerMap +>HandlerMap : { foo: (x: string) => void; bar: (x: number) => void; } >x : TypeMap[P] const handlers: HandlerMap = { @@ -276,7 +276,7 @@ process([{ type: 'foo', data: 'abc' }]); // -------- type LetterMap = { A: string, B: number } ->LetterMap : LetterMap +>LetterMap : { A: string; B: number; } >A : string >B : number @@ -298,19 +298,19 @@ function call({ letter, caller }: LetterCaller): v } type A = { A: string }; ->A : A +>A : { A: string; } >A : string type B = { B: number }; ->B : B +>B : { B: number; } >B : number type ACaller = (a: A) => void; ->ACaller : ACaller +>ACaller : (a: A) => void >a : A type BCaller = (b: B) => void; ->BCaller : BCaller +>BCaller : (b: B) => void >b : B declare const xx: { letter: A, caller: ACaller } | { letter: B, caller: BCaller }; @@ -552,7 +552,7 @@ function ff1() { // Repro from #47368 type ArgMap = { a: number, b: string }; ->ArgMap : ArgMap +>ArgMap : { a: number; b: string; } >a : number >b : string @@ -561,7 +561,7 @@ type Func = (x: ArgMap[K]) => void; >x : ArgMap[K] type Funcs = { [K in keyof ArgMap]: Func }; ->Funcs : Funcs +>Funcs : { a: Func<"a">; b: Func<"b">; } function f1(funcs: Funcs, key: K, arg: ArgMap[K]) { >f1 : (funcs: Funcs, key: K, arg: ArgMap[K]) => void @@ -751,5 +751,5 @@ type BarLookup = typeof BAR_LOOKUP; >BAR_LOOKUP : { a: { readonly name: "a"; }; b: { readonly name: "b"; }; } type Baz = { [K in keyof BarLookup]: BarLookup[K]['name'] }; ->Baz : Baz +>Baz : { a: "a"; b: "b"; } diff --git a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types index 7d9ce4aa34b65..d5a97ecb392da 100644 --- a/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types +++ b/tests/baselines/reference/crashInGetTextOfComputedPropertyName.types @@ -7,7 +7,7 @@ export interface B { type: 'b' } >type : "b" export type AB = A | B ->AB : AB +>AB : A | B const itemId = 'some-id' >itemId : "some-id" diff --git a/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types b/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types index 4f8a9cf021867..290628c7128c6 100644 --- a/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types +++ b/tests/baselines/reference/declFileTypeAnnotationTypeAlias.types @@ -3,7 +3,7 @@ module M { >M : typeof M export type Value = string | number | boolean; ->Value : Value +>Value : string | number | boolean export var x: Value; >x : Value @@ -28,7 +28,7 @@ module M { >m : any export type fc = () => c; ->fc : fc +>fc : () => c } interface Window { @@ -40,7 +40,7 @@ module M { >M : typeof M export type W = Window | string; ->W : W +>W : string | Window export module N { >N : typeof N diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types index e1f08d5893836..06ca2c0f0cb61 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types @@ -8,7 +8,7 @@ module M { >M : typeof M type W = Window | string; ->W : W +>W : string | Window export module N { >N : typeof N @@ -25,7 +25,7 @@ module M1 { >M1 : typeof M1 export type W = Window | string; ->W : W +>W : string | Window export module N { >N : typeof N diff --git a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types index a663e3283eae6..db3aae7ef4d8b 100644 --- a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types +++ b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types @@ -1,6 +1,6 @@ === tests/cases/compiler/locale.d.ts === export type Locale = { ->Locale : Locale +>Locale : { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string];}; } weekdays: { >weekdays : { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; } @@ -14,7 +14,7 @@ export type Locale = { }; }; export type CustomLocale = { ->CustomLocale : CustomLocale +>CustomLocale : { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string];}; } weekdays: { >weekdays : { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; } @@ -28,7 +28,7 @@ export type CustomLocale = { }; }; export type key = "ar" | "bg"; ->key : key +>key : "ar" | "bg" === tests/cases/compiler/instance.d.ts === import { Locale, CustomLocale, key as LocaleKey } from "./locale"; diff --git a/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types index d76fd67f9d65a..47f57b4693b1c 100644 --- a/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types +++ b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types @@ -10,7 +10,7 @@ class C1 { } type TupleType1 =[string, number, boolean]; ->TupleType1 : TupleType1 +>TupleType1 : [string, number, boolean] class C2 { >C2 : C2 @@ -23,7 +23,7 @@ class C2 { } type ObjType1 = { x: number; y: string; z: boolean } ->ObjType1 : ObjType1 +>ObjType1 : { x: number; y: string; z: boolean; } >x : number >y : string >z : boolean diff --git a/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types index bf9666f3082b1..28684e8ea851c 100644 --- a/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types +++ b/tests/baselines/reference/declarationEmitExportAliasVisibiilityMarking.types @@ -1,9 +1,9 @@ === tests/cases/compiler/Types.ts === type Suit = 'Hearts' | 'Spades' | 'Clubs' | 'Diamonds'; ->Suit : Suit +>Suit : "Hearts" | "Spades" | "Clubs" | "Diamonds" type Rank = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 'Jack' | 'Queen' | 'King'; ->Rank : Rank +>Rank : 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | "Jack" | "Queen" | "King" export { Suit, Rank }; >Suit : any diff --git a/tests/baselines/reference/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.types b/tests/baselines/reference/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.types index 3582fd3db6b80..b92654ce3811c 100644 --- a/tests/baselines/reference/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.types +++ b/tests/baselines/reference/declarationEmitExpressionWithNonlocalPrivateUniqueSymbol.types @@ -1,6 +1,6 @@ === tests/cases/compiler/a.ts === type AX = { readonly A: unique symbol }; ->AX : AX +>AX : { readonly A: unique symbol; } >A : unique symbol export const A: AX = 0 as any; diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias5.types b/tests/baselines/reference/declarationEmitInferredTypeAlias5.types index 63d2cec4b9a99..98a575c0631c1 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias5.types +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias5.types @@ -1,6 +1,6 @@ === tests/cases/compiler/0.ts === export type Data = string | boolean; ->Data : Data +>Data : string | boolean let obj: Data = true; >obj : Data diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias7.types b/tests/baselines/reference/declarationEmitInferredTypeAlias7.types index a035da8453fcc..572315d62ff8a 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias7.types +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias7.types @@ -1,6 +1,6 @@ === tests/cases/compiler/0.ts === export type Data = string | boolean; ->Data : Data +>Data : string | boolean let obj: Data = true; >obj : Data diff --git a/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.js b/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.js new file mode 100644 index 0000000000000..fafb13d1d5c79 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.js @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/declarationEmitInlinedDistributiveConditional.ts] //// + +//// [test.ts] +import {dropPrivateProps1, dropPrivateProps2} from './api'; +const a = dropPrivateProps1({foo: 42, _bar: 'secret'}); // type is {foo: number} +//a._bar // error: _bar does not exist <===== as expected +const b = dropPrivateProps2({foo: 42, _bar: 'secret'}); // type is {foo: number, _bar: string} +//b._bar // no error, type of b._bar is string <===== NOT expected + +//// [api.ts] +import {excludePrivateKeys1, excludePrivateKeys2} from './internal'; +export const dropPrivateProps1 = (obj: Obj) => excludePrivateKeys1(obj); +export const dropPrivateProps2 = (obj: Obj) => excludePrivateKeys2(obj); + +//// [internal.ts] +export declare function excludePrivateKeys1(obj: Obj): {[K in PublicKeys1]: Obj[K]}; +export declare function excludePrivateKeys2(obj: Obj): {[K in PublicKeys2]: Obj[K]}; +export type PublicKeys1 = T extends `_${string}` ? never : T; +type PublicKeys2 = T extends `_${string}` ? never : T; + +//// [internal.js] +"use strict"; +exports.__esModule = true; +//// [api.js] +"use strict"; +exports.__esModule = true; +exports.dropPrivateProps2 = exports.dropPrivateProps1 = void 0; +var internal_1 = require("./internal"); +var dropPrivateProps1 = function (obj) { return (0, internal_1.excludePrivateKeys1)(obj); }; +exports.dropPrivateProps1 = dropPrivateProps1; +var dropPrivateProps2 = function (obj) { return (0, internal_1.excludePrivateKeys2)(obj); }; +exports.dropPrivateProps2 = dropPrivateProps2; +//// [test.js] +"use strict"; +exports.__esModule = true; +var api_1 = require("./api"); +var a = (0, api_1.dropPrivateProps1)({ foo: 42, _bar: 'secret' }); // type is {foo: number} +//a._bar // error: _bar does not exist <===== as expected +var b = (0, api_1.dropPrivateProps2)({ foo: 42, _bar: 'secret' }); // type is {foo: number, _bar: string} +//b._bar // no error, type of b._bar is string <===== NOT expected + + +//// [internal.d.ts] +export declare function excludePrivateKeys1(obj: Obj): { + [K in PublicKeys1]: Obj[K]; +}; +export declare function excludePrivateKeys2(obj: Obj): { + [K in PublicKeys2]: Obj[K]; +}; +export declare type PublicKeys1 = T extends `_${string}` ? never : T; +declare type PublicKeys2 = T extends `_${string}` ? never : T; +export {}; +//// [api.d.ts] +export declare const dropPrivateProps1: (obj: Obj) => { [K in import("./internal").PublicKeys1]: Obj[K]; }; +export declare const dropPrivateProps2: (obj: Obj) => { [K in keyof Obj extends infer T ? T extends keyof Obj ? T extends `_${string}` ? never : T : never : never]: Obj[K]; }; +//// [test.d.ts] +export {}; diff --git a/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.symbols b/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.symbols new file mode 100644 index 0000000000000..8931694249369 --- /dev/null +++ b/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.symbols @@ -0,0 +1,76 @@ +=== tests/cases/compiler/test.ts === +import {dropPrivateProps1, dropPrivateProps2} from './api'; +>dropPrivateProps1 : Symbol(dropPrivateProps1, Decl(test.ts, 0, 8)) +>dropPrivateProps2 : Symbol(dropPrivateProps2, Decl(test.ts, 0, 26)) + +const a = dropPrivateProps1({foo: 42, _bar: 'secret'}); // type is {foo: number} +>a : Symbol(a, Decl(test.ts, 1, 5)) +>dropPrivateProps1 : Symbol(dropPrivateProps1, Decl(test.ts, 0, 8)) +>foo : Symbol(foo, Decl(test.ts, 1, 29)) +>_bar : Symbol(_bar, Decl(test.ts, 1, 37)) + +//a._bar // error: _bar does not exist <===== as expected +const b = dropPrivateProps2({foo: 42, _bar: 'secret'}); // type is {foo: number, _bar: string} +>b : Symbol(b, Decl(test.ts, 3, 5)) +>dropPrivateProps2 : Symbol(dropPrivateProps2, Decl(test.ts, 0, 26)) +>foo : Symbol(foo, Decl(test.ts, 3, 29)) +>_bar : Symbol(_bar, Decl(test.ts, 3, 37)) + +//b._bar // no error, type of b._bar is string <===== NOT expected + +=== tests/cases/compiler/api.ts === +import {excludePrivateKeys1, excludePrivateKeys2} from './internal'; +>excludePrivateKeys1 : Symbol(excludePrivateKeys1, Decl(api.ts, 0, 8)) +>excludePrivateKeys2 : Symbol(excludePrivateKeys2, Decl(api.ts, 0, 28)) + +export const dropPrivateProps1 = (obj: Obj) => excludePrivateKeys1(obj); +>dropPrivateProps1 : Symbol(dropPrivateProps1, Decl(api.ts, 1, 12)) +>Obj : Symbol(Obj, Decl(api.ts, 1, 34)) +>obj : Symbol(obj, Decl(api.ts, 1, 39)) +>Obj : Symbol(Obj, Decl(api.ts, 1, 34)) +>excludePrivateKeys1 : Symbol(excludePrivateKeys1, Decl(api.ts, 0, 8)) +>obj : Symbol(obj, Decl(api.ts, 1, 39)) + +export const dropPrivateProps2 = (obj: Obj) => excludePrivateKeys2(obj); +>dropPrivateProps2 : Symbol(dropPrivateProps2, Decl(api.ts, 2, 12)) +>Obj : Symbol(Obj, Decl(api.ts, 2, 34)) +>obj : Symbol(obj, Decl(api.ts, 2, 39)) +>Obj : Symbol(Obj, Decl(api.ts, 2, 34)) +>excludePrivateKeys2 : Symbol(excludePrivateKeys2, Decl(api.ts, 0, 28)) +>obj : Symbol(obj, Decl(api.ts, 2, 39)) + +=== tests/cases/compiler/internal.ts === +export declare function excludePrivateKeys1(obj: Obj): {[K in PublicKeys1]: Obj[K]}; +>excludePrivateKeys1 : Symbol(excludePrivateKeys1, Decl(internal.ts, 0, 0)) +>Obj : Symbol(Obj, Decl(internal.ts, 0, 44)) +>obj : Symbol(obj, Decl(internal.ts, 0, 49)) +>Obj : Symbol(Obj, Decl(internal.ts, 0, 44)) +>K : Symbol(K, Decl(internal.ts, 0, 62)) +>PublicKeys1 : Symbol(PublicKeys1, Decl(internal.ts, 1, 100)) +>Obj : Symbol(Obj, Decl(internal.ts, 0, 44)) +>Obj : Symbol(Obj, Decl(internal.ts, 0, 44)) +>K : Symbol(K, Decl(internal.ts, 0, 62)) + +export declare function excludePrivateKeys2(obj: Obj): {[K in PublicKeys2]: Obj[K]}; +>excludePrivateKeys2 : Symbol(excludePrivateKeys2, Decl(internal.ts, 0, 100)) +>Obj : Symbol(Obj, Decl(internal.ts, 1, 44)) +>obj : Symbol(obj, Decl(internal.ts, 1, 49)) +>Obj : Symbol(Obj, Decl(internal.ts, 1, 44)) +>K : Symbol(K, Decl(internal.ts, 1, 62)) +>PublicKeys2 : Symbol(PublicKeys2, Decl(internal.ts, 2, 64)) +>Obj : Symbol(Obj, Decl(internal.ts, 1, 44)) +>Obj : Symbol(Obj, Decl(internal.ts, 1, 44)) +>K : Symbol(K, Decl(internal.ts, 1, 62)) + +export type PublicKeys1 = T extends `_${string}` ? never : T; +>PublicKeys1 : Symbol(PublicKeys1, Decl(internal.ts, 1, 100)) +>T : Symbol(T, Decl(internal.ts, 2, 24)) +>T : Symbol(T, Decl(internal.ts, 2, 24)) +>T : Symbol(T, Decl(internal.ts, 2, 24)) + +type PublicKeys2 = T extends `_${string}` ? never : T; +>PublicKeys2 : Symbol(PublicKeys2, Decl(internal.ts, 2, 64)) +>T : Symbol(T, Decl(internal.ts, 3, 17)) +>T : Symbol(T, Decl(internal.ts, 3, 17)) +>T : Symbol(T, Decl(internal.ts, 3, 17)) + diff --git a/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.types b/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.types new file mode 100644 index 0000000000000..ba779f2eebcef --- /dev/null +++ b/tests/baselines/reference/declarationEmitInlinedDistributiveConditional.types @@ -0,0 +1,64 @@ +=== tests/cases/compiler/test.ts === +import {dropPrivateProps1, dropPrivateProps2} from './api'; +>dropPrivateProps1 : (obj: Obj) => { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>dropPrivateProps2 : (obj: Obj) => { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } + +const a = dropPrivateProps1({foo: 42, _bar: 'secret'}); // type is {foo: number} +>a : { foo: number; } +>dropPrivateProps1({foo: 42, _bar: 'secret'}) : { foo: number; } +>dropPrivateProps1 : (obj: Obj) => { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>{foo: 42, _bar: 'secret'} : { foo: number; _bar: string; } +>foo : number +>42 : 42 +>_bar : string +>'secret' : "secret" + +//a._bar // error: _bar does not exist <===== as expected +const b = dropPrivateProps2({foo: 42, _bar: 'secret'}); // type is {foo: number, _bar: string} +>b : { foo: number; } +>dropPrivateProps2({foo: 42, _bar: 'secret'}) : { foo: number; } +>dropPrivateProps2 : (obj: Obj) => { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } +>{foo: 42, _bar: 'secret'} : { foo: number; _bar: string; } +>foo : number +>42 : 42 +>_bar : string +>'secret' : "secret" + +//b._bar // no error, type of b._bar is string <===== NOT expected + +=== tests/cases/compiler/api.ts === +import {excludePrivateKeys1, excludePrivateKeys2} from './internal'; +>excludePrivateKeys1 : (obj: Obj) => { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>excludePrivateKeys2 : (obj: Obj) => { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } + +export const dropPrivateProps1 = (obj: Obj) => excludePrivateKeys1(obj); +>dropPrivateProps1 : (obj: Obj) => { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>(obj: Obj) => excludePrivateKeys1(obj) : (obj: Obj) => { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>obj : Obj +>excludePrivateKeys1(obj) : { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>excludePrivateKeys1 : (obj: Obj) => { [K in import("tests/cases/compiler/internal").PublicKeys1]: Obj[K]; } +>obj : Obj + +export const dropPrivateProps2 = (obj: Obj) => excludePrivateKeys2(obj); +>dropPrivateProps2 : (obj: Obj) => { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } +>(obj: Obj) => excludePrivateKeys2(obj) : (obj: Obj) => { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } +>obj : Obj +>excludePrivateKeys2(obj) : { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } +>excludePrivateKeys2 : (obj: Obj) => { [K in keyof Obj extends `_${string}` ? never : keyof Obj]: Obj[K]; } +>obj : Obj + +=== tests/cases/compiler/internal.ts === +export declare function excludePrivateKeys1(obj: Obj): {[K in PublicKeys1]: Obj[K]}; +>excludePrivateKeys1 : (obj: Obj) => { [K in PublicKeys1]: Obj[K]; } +>obj : Obj + +export declare function excludePrivateKeys2(obj: Obj): {[K in PublicKeys2]: Obj[K]}; +>excludePrivateKeys2 : (obj: Obj) => { [K in PublicKeys2]: Obj[K]; } +>obj : Obj + +export type PublicKeys1 = T extends `_${string}` ? never : T; +>PublicKeys1 : PublicKeys1 + +type PublicKeys2 = T extends `_${string}` ? never : T; +>PublicKeys2 : PublicKeys2 + diff --git a/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.js b/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.js new file mode 100644 index 0000000000000..19319bc28e347 --- /dev/null +++ b/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.js @@ -0,0 +1,38 @@ +//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts] +export interface Foo { + item: Bar; +} + +interface Bar { + baz(): void; +} + +namespace Bar { + export function biz() { + return 0; + } +} + +//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.js] +"use strict"; +exports.__esModule = true; +var Bar; +(function (Bar) { + function biz() { + return 0; + } + Bar.biz = biz; +})(Bar || (Bar = {})); + + +//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.d.ts] +export interface Foo { + item: Bar; +} +interface Bar { + baz(): void; +} +declare namespace Bar { + function biz(): number; +} +export {}; diff --git a/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.symbols b/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.symbols new file mode 100644 index 0000000000000..45afcfb0df027 --- /dev/null +++ b/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts === +export interface Foo { +>Foo : Symbol(Foo, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 0, 0)) + + item: Bar; +>item : Symbol(Foo.item, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 0, 22)) +>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1)) +} + +interface Bar { +>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1)) + + baz(): void; +>baz : Symbol(Bar.baz, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 4, 15)) +} + +namespace Bar { +>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1)) + + export function biz() { +>biz : Symbol(biz, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 8, 15)) + + return 0; + } +} diff --git a/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.types b/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.types new file mode 100644 index 0000000000000..c6df96fb5a071 --- /dev/null +++ b/tests/baselines/reference/declarationEmitNamespaceMergedWithInterfaceNestedFunction.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts === +export interface Foo { + item: Bar; +>item : Bar +} + +interface Bar { + baz(): void; +>baz : () => void +} + +namespace Bar { +>Bar : typeof Bar + + export function biz() { +>biz : () => number + + return 0; +>0 : 0 + } +} diff --git a/tests/baselines/reference/declarationEmitPathMappingMonorepo.types b/tests/baselines/reference/declarationEmitPathMappingMonorepo.types index 8c4c1678c2967..d4fe2b7157b9a 100644 --- a/tests/baselines/reference/declarationEmitPathMappingMonorepo.types +++ b/tests/baselines/reference/declarationEmitPathMappingMonorepo.types @@ -3,7 +3,7 @@ declare module "@ts-bug/a" { >"@ts-bug/a" : typeof import("@ts-bug/a") export type AText = { ->AText : AText +>AText : { value: string; } value: string; >value : string diff --git a/tests/baselines/reference/declarationEmitQualifiedAliasTypeArgument.types b/tests/baselines/reference/declarationEmitQualifiedAliasTypeArgument.types index e95f15377cc02..2e947507af8af 100644 --- a/tests/baselines/reference/declarationEmitQualifiedAliasTypeArgument.types +++ b/tests/baselines/reference/declarationEmitQualifiedAliasTypeArgument.types @@ -24,10 +24,10 @@ export enum E { } export type T = G; ->T : T +>T : { a: string; b: string; } export type Q = G; ->Q : Q +>Q : { a: string; } >E : any === tests/cases/compiler/index.ts === diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.types b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.types index 50c770d525718..0ed089b529a91 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.types +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.types @@ -2,21 +2,21 @@ export * from './types'; No type information for this code.=== tests/cases/compiler/monorepo/pkg1/dist/types.d.ts === export declare type A = { ->A : A +>A : { id: string; } id: string; >id : string }; export declare type B = { ->B : B +>B : { id: number; } id: number; >id : number }; export declare type IdType = A | B; ->IdType : IdType +>IdType : A | B export declare class MetadataAccessor { >MetadataAccessor : MetadataAccessor diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.types b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.types index 1ecb9e7592298..e52c244ccc5a4 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.types +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.types @@ -2,21 +2,21 @@ export * from './types'; No type information for this code.=== tests/cases/compiler/monorepo/pkg1/dist/types.d.ts === export declare type A = { ->A : A +>A : { id: string; } id: string; >id : string }; export declare type B = { ->B : B +>B : { id: number; } id: number; >id : number }; export declare type IdType = A | B; ->IdType : IdType +>IdType : A | B export declare class MetadataAccessor { >MetadataAccessor : MetadataAccessor diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.types b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.types index e3f8347888466..06272b7baa950 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.types +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.types @@ -2,21 +2,21 @@ export * from './types'; No type information for this code.=== tests/cases/compiler/monorepo/pkg1/dist/types.d.ts === export declare type A = { ->A : A +>A : { id: string; } id: string; >id : string }; export declare type B = { ->B : B +>B : { id: number; } id: number; >id : number }; export declare type IdType = A | B; ->IdType : IdType +>IdType : A | B export declare class MetadataAccessor { >MetadataAccessor : MetadataAccessor diff --git a/tests/baselines/reference/declarationEmitSymlinkPaths.types b/tests/baselines/reference/declarationEmitSymlinkPaths.types index 2d79f6b4cc847..2b16d631796a5 100644 --- a/tests/baselines/reference/declarationEmitSymlinkPaths.types +++ b/tests/baselines/reference/declarationEmitSymlinkPaths.types @@ -5,10 +5,10 @@ export declare function test (a: () => T): () => T; === /packages/search-prefix/src/API/NotificationAPIUtils.ts === export type NotificationRequest = {}; ->NotificationRequest : NotificationRequest +>NotificationRequest : {} export type NotificationResponse = {}; ->NotificationResponse : NotificationResponse +>NotificationResponse : {} export function getNotification(): NotificationResponse { >getNotification : () => NotificationResponse diff --git a/tests/baselines/reference/declarationsForFileShadowingGlobalNoError.types b/tests/baselines/reference/declarationsForFileShadowingGlobalNoError.types index c15ad37bccca8..1c766f91ab2d0 100644 --- a/tests/baselines/reference/declarationsForFileShadowingGlobalNoError.types +++ b/tests/baselines/reference/declarationsForFileShadowingGlobalNoError.types @@ -4,7 +4,7 @@ export type DOMNode = Node; === tests/cases/compiler/custom.ts === export type Node = {}; ->Node : Node +>Node : {} === tests/cases/compiler/index.ts === import { Node } from './custom' @@ -14,7 +14,7 @@ import { DOMNode } from './dom' >DOMNode : any type Constructor = new (...args: any[]) => any ->Constructor : Constructor +>Constructor : new (...args: any[]) => any >args : any[] export const mixin = (Base: Constructor) => { diff --git a/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types b/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types index 85ebfca651f13..dfad078a2f35e 100644 --- a/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types +++ b/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types @@ -15,7 +15,7 @@ interface Hash { } type StringHash = Hash; ->StringHash : StringHash +>StringHash : Hash interface StringHash2 extends Hash {} === tests/cases/compiler/a.ts === diff --git a/tests/baselines/reference/deeplyNestedConstraints.types b/tests/baselines/reference/deeplyNestedConstraints.types index 2d8d34729068e..64eb0f1b2103f 100644 --- a/tests/baselines/reference/deeplyNestedConstraints.types +++ b/tests/baselines/reference/deeplyNestedConstraints.types @@ -2,7 +2,7 @@ // Repro from #41931 type Enum = Record; ->Enum : Enum +>Enum : { [x: string]: string | number; } type TypeMap = { [key in E[keyof E]]: number | boolean | string | number[] }; >TypeMap : TypeMap diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types index ef1aca3806809..06b51c2eeace6 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types @@ -1,6 +1,6 @@ === tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts === function f(addUndefined1 = "J", addUndefined2?: number) { ->f : (addUndefined1?: string, addUndefined2?: number | undefined) => number +>f : (addUndefined1?: string, addUndefined2?: number) => number >addUndefined1 : string >"J" : "J" >addUndefined2 : number | undefined @@ -117,7 +117,7 @@ function foo4(x: string | undefined = undefined, b: number) { } type OptionalNullableString = string | null | undefined; ->OptionalNullableString : OptionalNullableString +>OptionalNullableString : string | null | undefined >null : null function allowsNull(val: OptionalNullableString = "") { diff --git a/tests/baselines/reference/deferredTypeReferenceWithinArrayWithinTuple.types b/tests/baselines/reference/deferredTypeReferenceWithinArrayWithinTuple.types index f7a124d6ae92e..147d183e05ea5 100644 --- a/tests/baselines/reference/deferredTypeReferenceWithinArrayWithinTuple.types +++ b/tests/baselines/reference/deferredTypeReferenceWithinArrayWithinTuple.types @@ -1,6 +1,6 @@ === tests/cases/compiler/deferredTypeReferenceWithinArrayWithinTuple.ts === type TypeStructure = ->TypeStructure : TypeStructure +>TypeStructure : ["or", TypeStructure[]] | ["string"] | ["number"] | ["list", TypeStructure] | ["or", TypeStructure[]] // problem is only here, when using array | ["string"] diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types index 371bb25e96d82..a1b5f6359a88d 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types @@ -37,7 +37,7 @@ interface AA { } type BB = { ->BB : BB +>BB : { [x: string]: number; } [P in keyof any]: number } diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types index a3d6f52b7c436..b2277d20f6114 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types @@ -37,7 +37,7 @@ interface AA { } type BB = { ->BB : BB +>BB : { [x: string]: number; } [P in keyof any]: number } diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).types b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).types index 79da5d0fe05d4..36da93480e881 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).types +++ b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=false).types @@ -37,7 +37,7 @@ interface AA { } type BB = { ->BB : BB +>BB : { [x: string]: number; } [P in keyof any]: number } diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).types b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).types index 79da5d0fe05d4..36da93480e881 100644 --- a/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).types +++ b/tests/baselines/reference/deleteExpressionMustBeOptional_exactOptionalPropertyTypes(exactoptionalpropertytypes=true).types @@ -37,7 +37,7 @@ interface AA { } type BB = { ->BB : BB +>BB : { [x: string]: number; } [P in keyof any]: number } diff --git a/tests/baselines/reference/dependentDestructuredVariables.errors.txt b/tests/baselines/reference/dependentDestructuredVariables.errors.txt new file mode 100644 index 0000000000000..fbddf80744cc8 --- /dev/null +++ b/tests/baselines/reference/dependentDestructuredVariables.errors.txt @@ -0,0 +1,334 @@ +tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts(314,5): error TS7022: 'value1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts(314,5): error TS7031: Binding element 'value1' implicitly has an 'any' type. + + +==== tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts (2 errors) ==== + type Action = + | { kind: 'A', payload: number } + | { kind: 'B', payload: string }; + + function f10({ kind, payload }: Action) { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + + function f11(action: Action) { + const { kind, payload } = action; + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + + function f12({ kind, payload }: Action) { + switch (kind) { + case 'A': + payload.toFixed(); + break; + case 'B': + payload.toUpperCase(); + break; + default: + payload; // never + } + } + + type Action2 = + | { kind: 'A', payload: number | undefined } + | { kind: 'B', payload: string | undefined }; + + function f20({ kind, payload }: Action2) { + if (payload) { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + } + + function f21(action: Action2) { + const { kind, payload } = action; + if (payload) { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + } + + function f22(action: Action2) { + if (action.payload) { + const { kind, payload } = action; + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + } + + function f23({ kind, payload }: Action2) { + if (payload) { + switch (kind) { + case 'A': + payload.toFixed(); + break; + case 'B': + payload.toUpperCase(); + break; + default: + payload; // never + } + } + } + + type Foo = + | { kind: 'A', isA: true } + | { kind: 'B', isA: false } + | { kind: 'C', isA: false }; + + function f30({ kind, isA }: Foo) { + if (kind === 'A') { + isA; // true + } + if (kind === 'B') { + isA; // false + } + if (kind === 'C') { + isA; // false + } + if (isA) { + kind; // 'A' + } + else { + kind; // 'B' | 'C' + } + } + + type Args = ['A', number] | ['B', string] + + function f40(...[kind, data]: Args) { + if (kind === 'A') { + data.toFixed(); + } + if (kind === 'B') { + data.toUpperCase(); + } + } + + // Repro from #35283 + + interface A { variant: 'a', value: T } + + interface B { variant: 'b', value: Array } + + type AB = A | B; + + declare function printValue(t: T): void; + + declare function printValueList(t: Array): void; + + function unrefined1(ab: AB): void { + const { variant, value } = ab; + if (variant === 'a') { + printValue(value); + } + else { + printValueList(value); + } + } + + // Repro from #38020 + + type Action3 = + | {type: 'add', payload: { toAdd: number } } + | {type: 'remove', payload: { toRemove: number } }; + + const reducerBroken = (state: number, { type, payload }: Action3) => { + switch (type) { + case 'add': + return state + payload.toAdd; + case 'remove': + return state - payload.toRemove; + } + } + + // Repro from #46143 + + declare var it: Iterator; + const { value, done } = it.next(); + if (!done) { + value; // number + } + + // Repro from #46658 + + declare function f50(cb: (...args: Args) => void): void + + f50((kind, data) => { + if (kind === 'A') { + data.toFixed(); + } + if (kind === 'B') { + data.toUpperCase(); + } + }); + + const f51: (...args: ['A', number] | ['B', string]) => void = (kind, payload) => { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + }; + + const f52: (...args: ['A', number] | ['B']) => void = (kind, payload?) => { + if (kind === 'A') { + payload.toFixed(); + } + else { + payload; // undefined + } + }; + + declare function readFile(path: string, callback: (...args: [err: null, data: unknown[]] | [err: Error, data: undefined]) => void): void; + + readFile('hello', (err, data) => { + if (err === null) { + data.length; + } + else { + err.message; + } + }); + + type ReducerArgs = ["add", { a: number, b: number }] | ["concat", { firstArr: any[], secondArr: any[] }]; + + const reducer: (...args: ReducerArgs) => void = (op, args) => { + switch (op) { + case "add": + console.log(args.a + args.b); + break; + case "concat": + console.log(args.firstArr.concat(args.secondArr)); + break; + } + } + + reducer("add", { a: 1, b: 3 }); + reducer("concat", { firstArr: [1, 2], secondArr: [3, 4] }); + + // repro from https://github.com/microsoft/TypeScript/pull/47190#issuecomment-1057603588 + + type FooMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): void; + } + + let fooM: FooMethod = { + method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + type FooAsyncMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): Promise; + } + + let fooAsyncM: FooAsyncMethod = { + async method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + type FooGenMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): Generator; + } + + let fooGenM: FooGenMethod = { + *method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + type FooAsyncGenMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): AsyncGenerator; + } + + let fooAsyncGenM: FooAsyncGenMethod = { + async *method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + // Repro from #48345 + + type Func = (...args: T) => void; + + const f60: Func = (kind, payload) => { + if (kind === "a") { + payload.toFixed(); // error + } + if (kind === "b") { + payload.toUpperCase(); // error + } + }; + + // Repro from #48902 + + function foo({ + value1, + ~~~~~~ +!!! error TS7022: 'value1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~~~~~~ +!!! error TS7031: Binding element 'value1' implicitly has an 'any' type. + test1 = value1.test1, + test2 = value1.test2, + test3 = value1.test3, + test4 = value1.test4, + test5 = value1.test5, + test6 = value1.test6, + test7 = value1.test7, + test8 = value1.test8, + test9 = value1.test9 + }) {} + \ No newline at end of file diff --git a/tests/baselines/reference/dependentDestructuredVariables.js b/tests/baselines/reference/dependentDestructuredVariables.js index a9f2006ec1e7a..eab12767faf7a 100644 --- a/tests/baselines/reference/dependentDestructuredVariables.js +++ b/tests/baselines/reference/dependentDestructuredVariables.js @@ -308,6 +308,21 @@ const f60: Func = (kind, payload) => { payload.toUpperCase(); // error } }; + +// Repro from #48902 + +function foo({ + value1, + test1 = value1.test1, + test2 = value1.test2, + test3 = value1.test3, + test4 = value1.test4, + test5 = value1.test5, + test6 = value1.test6, + test7 = value1.test7, + test8 = value1.test8, + test9 = value1.test9 +}) {} //// [dependentDestructuredVariables.js] @@ -550,6 +565,8 @@ const f60 = (kind, payload) => { payload.toUpperCase(); // error } }; +// Repro from #48902 +function foo({ value1, test1 = value1.test1, test2 = value1.test2, test3 = value1.test3, test4 = value1.test4, test5 = value1.test5, test6 = value1.test6, test7 = value1.test7, test8 = value1.test8, test9 = value1.test9 }) { } //// [dependentDestructuredVariables.d.ts] @@ -667,3 +684,15 @@ declare type FooAsyncGenMethod = { declare let fooAsyncGenM: FooAsyncGenMethod; declare type Func = (...args: T) => void; declare const f60: Func; +declare function foo({ value1, test1, test2, test3, test4, test5, test6, test7, test8, test9 }: { + value1: any; + test1?: any; + test2?: any; + test3?: any; + test4?: any; + test5?: any; + test6?: any; + test7?: any; + test8?: any; + test9?: any; +}): void; diff --git a/tests/baselines/reference/dependentDestructuredVariables.symbols b/tests/baselines/reference/dependentDestructuredVariables.symbols index f859b5ee7566f..ccaaaa72fe9d0 100644 --- a/tests/baselines/reference/dependentDestructuredVariables.symbols +++ b/tests/baselines/reference/dependentDestructuredVariables.symbols @@ -784,3 +784,49 @@ const f60: Func = (kind, payload) => { } }; +// Repro from #48902 + +function foo({ +>foo : Symbol(foo, Decl(dependentDestructuredVariables.ts, 308, 2)) + + value1, +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test1 = value1.test1, +>test1 : Symbol(test1, Decl(dependentDestructuredVariables.ts, 313, 11)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test2 = value1.test2, +>test2 : Symbol(test2, Decl(dependentDestructuredVariables.ts, 314, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test3 = value1.test3, +>test3 : Symbol(test3, Decl(dependentDestructuredVariables.ts, 315, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test4 = value1.test4, +>test4 : Symbol(test4, Decl(dependentDestructuredVariables.ts, 316, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test5 = value1.test5, +>test5 : Symbol(test5, Decl(dependentDestructuredVariables.ts, 317, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test6 = value1.test6, +>test6 : Symbol(test6, Decl(dependentDestructuredVariables.ts, 318, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test7 = value1.test7, +>test7 : Symbol(test7, Decl(dependentDestructuredVariables.ts, 319, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test8 = value1.test8, +>test8 : Symbol(test8, Decl(dependentDestructuredVariables.ts, 320, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test9 = value1.test9 +>test9 : Symbol(test9, Decl(dependentDestructuredVariables.ts, 321, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + +}) {} + diff --git a/tests/baselines/reference/dependentDestructuredVariables.types b/tests/baselines/reference/dependentDestructuredVariables.types index bfc8a5f2fb882..f3f9024231324 100644 --- a/tests/baselines/reference/dependentDestructuredVariables.types +++ b/tests/baselines/reference/dependentDestructuredVariables.types @@ -1,6 +1,6 @@ === tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts === type Action = ->Action : Action +>Action : { kind: 'A'; payload: number; } | { kind: 'B'; payload: string; } | { kind: 'A', payload: number } >kind : "A" @@ -107,7 +107,7 @@ function f12({ kind, payload }: Action) { } type Action2 = ->Action2 : Action2 +>Action2 : { kind: 'A'; payload: number | undefined; } | { kind: 'B'; payload: string | undefined; } | { kind: 'A', payload: number | undefined } >kind : "A" @@ -265,7 +265,7 @@ function f23({ kind, payload }: Action2) { } type Foo = ->Foo : Foo +>Foo : { kind: 'A'; isA: true; } | { kind: 'B'; isA: false; } | { kind: 'C'; isA: false; } | { kind: 'A', isA: true } >kind : "A" @@ -324,7 +324,7 @@ function f30({ kind, isA }: Foo) { } type Args = ['A', number] | ['B', string] ->Args : Args +>Args : ["A", number] | ["B", string] function f40(...[kind, data]: Args) { >f40 : (...[kind, data]: Args) => void @@ -406,7 +406,7 @@ function unrefined1(ab: AB): void { // Repro from #38020 type Action3 = ->Action3 : Action3 +>Action3 : { type: 'add'; payload: { toAdd: number;}; } | { type: 'remove'; payload: { toRemove: number;}; } | {type: 'add', payload: { toAdd: number } } >type : "add" @@ -598,7 +598,7 @@ readFile('hello', (err, data) => { }); type ReducerArgs = ["add", { a: number, b: number }] | ["concat", { firstArr: any[], secondArr: any[] }]; ->ReducerArgs : ReducerArgs +>ReducerArgs : ["add", { a: number; b: number; }] | ["concat", { firstArr: any[]; secondArr: any[]; }] >a : number >b : number >firstArr : any[] @@ -680,7 +680,7 @@ reducer("concat", { firstArr: [1, 2], secondArr: [3, 4] }); // repro from https://github.com/microsoft/TypeScript/pull/47190#issuecomment-1057603588 type FooMethod = { ->FooMethod : FooMethod +>FooMethod : { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]): void; } method(...args: >method : (...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]) => void @@ -724,7 +724,7 @@ let fooM: FooMethod = { }; type FooAsyncMethod = { ->FooAsyncMethod : FooAsyncMethod +>FooAsyncMethod : { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]): Promise; } method(...args: >method : (...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]) => Promise @@ -768,7 +768,7 @@ let fooAsyncM: FooAsyncMethod = { }; type FooGenMethod = { ->FooGenMethod : FooGenMethod +>FooGenMethod : { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]): Generator; } method(...args: >method : (...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]) => Generator @@ -812,7 +812,7 @@ let fooGenM: FooGenMethod = { }; type FooAsyncGenMethod = { ->FooAsyncGenMethod : FooAsyncGenMethod +>FooAsyncGenMethod : { method(...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]): AsyncGenerator; } method(...args: >method : (...args: [type: "str", cb: (e: string) => void] | [type: "num", cb: (e: number) => void]) => AsyncGenerator @@ -858,7 +858,7 @@ let fooAsyncGenM: FooAsyncGenMethod = { // Repro from #48345 type Func = (...args: T) => void; ->Func : Func +>Func : (...args: T) => void >args : T const f60: Func = (kind, payload) => { @@ -891,3 +891,67 @@ const f60: Func = (kind, payload) => { } }; +// Repro from #48902 + +function foo({ +>foo : ({ value1, test1, test2, test3, test4, test5, test6, test7, test8, test9 }: { value1: any; test1?: any; test2?: any; test3?: any; test4?: any; test5?: any; test6?: any; test7?: any; test8?: any; test9?: any; }) => void + + value1, +>value1 : any + + test1 = value1.test1, +>test1 : any +>value1.test1 : any +>value1 : any +>test1 : any + + test2 = value1.test2, +>test2 : any +>value1.test2 : any +>value1 : any +>test2 : any + + test3 = value1.test3, +>test3 : any +>value1.test3 : any +>value1 : any +>test3 : any + + test4 = value1.test4, +>test4 : any +>value1.test4 : any +>value1 : any +>test4 : any + + test5 = value1.test5, +>test5 : any +>value1.test5 : any +>value1 : any +>test5 : any + + test6 = value1.test6, +>test6 : any +>value1.test6 : any +>value1 : any +>test6 : any + + test7 = value1.test7, +>test7 : any +>value1.test7 : any +>value1 : any +>test7 : any + + test8 = value1.test8, +>test8 : any +>value1.test8 : any +>value1 : any +>test8 : any + + test9 = value1.test9 +>test9 : any +>value1.test9 : any +>value1 : any +>test9 : any + +}) {} + diff --git a/tests/baselines/reference/destructureOptionalParameter.types b/tests/baselines/reference/destructureOptionalParameter.types index 984b2da856ae7..01b45c1cb4bf4 100644 --- a/tests/baselines/reference/destructureOptionalParameter.types +++ b/tests/baselines/reference/destructureOptionalParameter.types @@ -1,6 +1,6 @@ === tests/cases/compiler/destructureOptionalParameter.ts === declare function f1({ a, b }?: { a: number, b: string }): void; ->f1 : ({ a, b }?: { a: number; b: string; } | undefined) => void +>f1 : ({ a, b }?: { a: number; b: string;}) => void >a : number >b : string >a : number diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.types b/tests/baselines/reference/destructuringAssignmentWithDefault.types index 379bfe8b3bdbd..170d1d26ba509 100644 --- a/tests/baselines/reference/destructuringAssignmentWithDefault.types +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.types @@ -61,7 +61,7 @@ function f1(options?: { color?: string, width?: number }) { } function f2(options?: [string?, number?]) { ->f2 : (options?: [(string | undefined)?, (number | undefined)?] | undefined) => void +>f2 : (options?: [string?, number?]) => void >options : [(string | undefined)?, (number | undefined)?] | undefined let [str, num] = options || []; @@ -133,7 +133,7 @@ function f3(options?: { color: string, width: number }) { } function f4(options?: [string, number]) { ->f4 : (options?: [string, number] | undefined) => void +>f4 : (options?: [string, number]) => void >options : [string, number] | undefined let [str, num] = options || []; diff --git a/tests/baselines/reference/destructuringControlFlow.types b/tests/baselines/reference/destructuringControlFlow.types index 02deb39200688..9fc89eae51deb 100644 --- a/tests/baselines/reference/destructuringControlFlow.types +++ b/tests/baselines/reference/destructuringControlFlow.types @@ -161,7 +161,7 @@ function f4() { // Repro from #31770 type KeyValue = [string, string?]; ->KeyValue : KeyValue +>KeyValue : [string, (string | undefined)?] let [key, value]: KeyValue = ["foo"]; >key : string diff --git a/tests/baselines/reference/destructuringInFunctionType.types b/tests/baselines/reference/destructuringInFunctionType.types index b5b0ff041c62b..2b7f0de66ccf7 100644 --- a/tests/baselines/reference/destructuringInFunctionType.types +++ b/tests/baselines/reference/destructuringInFunctionType.types @@ -9,46 +9,46 @@ interface c { c } >c : any type T1 = ([a, b, c]); ->T1 : T1 +>T1 : [a, b, c] type F1 = ([a, b, c]) => void; ->F1 : F1 +>F1 : ([a, b, c]: [any, any, any]) => void >a : any >b : any >c : any type T2 = ({ a }); ->T2 : T2 +>T2 : { a: any; } >a : any type F2 = ({ a }) => void; ->F2 : F2 +>F2 : ({ a }: { a: any; }) => void >a : any type T3 = ([{ a: b }, { b: a }]); ->T3 : T3 +>T3 : [{ a: b; }, { b: a; }] >a : b >b : a type F3 = ([{ a: b }, { b: a }]) => void; ->F3 : F3 +>F3 : ([{ a: b }, { b: a }]: [{ a: any; }, { b: any; }]) => void >a : any >b : any >b : any >a : any type T4 = ([{ a: [b, c] }]); ->T4 : T4 +>T4 : [{ a: [b, c]; }] >a : [b, c] type F4 = ([{ a: [b, c] }]) => void; ->F4 : F4 +>F4 : ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void >a : any >b : any >c : any type C1 = new ([{ a: [b, c] }]) => void; ->C1 : C1 +>C1 : new ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void >a : any >b : any >c : any diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types index 80101e1013895..a7d9b02412a34 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : arrayString +>arrayString : String[] type someArray = Array | number[]; ->someArray : someArray +>someArray : String[] | number[] type stringOrNumArray = Array; ->stringOrNumArray : stringOrNumArray +>stringOrNumArray : (String | Number)[] function a1(...x: (number|string)[]) { } >a1 : (...x: (number | string)[]) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types index 02b43a1006dd0..f09b7387a33dc 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : arrayString +>arrayString : String[] type someArray = Array | number[]; ->someArray : someArray +>someArray : String[] | number[] type stringOrNumArray = Array; ->stringOrNumArray : stringOrNumArray +>stringOrNumArray : (String | Number)[] function a1(...x: (number|string)[]) { } >a1 : (...x: (number | string)[]) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types index a2e6a55203f2e..5d56b4163d697 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : arrayString +>arrayString : String[] type someArray = Array | number[]; ->someArray : someArray +>someArray : String[] | number[] type stringOrNumArray = Array; ->stringOrNumArray : stringOrNumArray +>stringOrNumArray : (String | Number)[] function a1(...x: (number|string)[]) { } >a1 : (...x: (number | string)[]) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.types b/tests/baselines/reference/destructuringParameterDeclaration4.types index 04e01920ee419..08a6474c44c0f 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.types +++ b/tests/baselines/reference/destructuringParameterDeclaration4.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : arrayString +>arrayString : String[] type someArray = Array | number[]; ->someArray : someArray +>someArray : String[] | number[] type stringOrNumArray = Array; ->stringOrNumArray : stringOrNumArray +>stringOrNumArray : (String | Number)[] function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type >a0 : (x_0: number, x_1: number, x_2: string) => void diff --git a/tests/baselines/reference/destructuringParameterProperties1.types b/tests/baselines/reference/destructuringParameterProperties1.types index 38174445dcac2..fc0b52893155f 100644 --- a/tests/baselines/reference/destructuringParameterProperties1.types +++ b/tests/baselines/reference/destructuringParameterProperties1.types @@ -10,7 +10,7 @@ class C1 { } type TupleType1 = [string, number, boolean]; ->TupleType1 : TupleType1 +>TupleType1 : [string, number, boolean] class C2 { >C2 : C2 @@ -23,7 +23,7 @@ class C2 { } type ObjType1 = { x: number; y: string; z: boolean } ->ObjType1 : ObjType1 +>ObjType1 : { x: number; y: string; z: boolean; } >x : number >y : string >z : boolean diff --git a/tests/baselines/reference/destructuringParameterProperties5.types b/tests/baselines/reference/destructuringParameterProperties5.types index 58d3b6d005dc6..ed95d0c196909 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.types +++ b/tests/baselines/reference/destructuringParameterProperties5.types @@ -1,12 +1,12 @@ === tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts === type ObjType1 = { x: number; y: string; z: boolean } ->ObjType1 : ObjType1 +>ObjType1 : { x: number; y: string; z: boolean; } >x : number >y : string >z : boolean type TupleType1 = [ObjType1, number, string] ->TupleType1 : TupleType1 +>TupleType1 : [ObjType1, number, string] class C1 { >C1 : C1 diff --git a/tests/baselines/reference/destructuringTypeGuardFlow.types b/tests/baselines/reference/destructuringTypeGuardFlow.types index 00953626899bd..7863be76c92e2 100644 --- a/tests/baselines/reference/destructuringTypeGuardFlow.types +++ b/tests/baselines/reference/destructuringTypeGuardFlow.types @@ -1,6 +1,6 @@ === tests/cases/compiler/destructuringTypeGuardFlow.ts === type foo = { ->foo : foo +>foo : { bar: number | null; baz: string; nested: { a: number; b: string | null;}; } bar: number | null; >bar : number | null @@ -79,7 +79,7 @@ if (aFoo.bar && aFoo.nested.b) { } type bar = { ->bar : bar +>bar : { elem1: number | null; elem2: foo | null; } elem1: number | null; >elem1 : number | null diff --git a/tests/baselines/reference/didYouMeanStringLiteral.types b/tests/baselines/reference/didYouMeanStringLiteral.types index c348534c65212..0cc503a11f526 100644 --- a/tests/baselines/reference/didYouMeanStringLiteral.types +++ b/tests/baselines/reference/didYouMeanStringLiteral.types @@ -1,6 +1,6 @@ === tests/cases/compiler/didYouMeanStringLiteral.ts === type T1 = "string" | "number" | "boolean"; ->T1 : T1 +>T1 : "string" | "number" | "boolean" type T2 = T1 & ("number" | "boolean"); // "number" | "boolean" >T2 : "number" | "boolean" diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.types b/tests/baselines/reference/directDependenceBetweenTypeAliases.types index e1d6784b327f8..7a031dd9a5f1d 100644 --- a/tests/baselines/reference/directDependenceBetweenTypeAliases.types +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.types @@ -17,7 +17,7 @@ type T0_3 = T0_1 // A type reference directly depends on the referenced type and each of the type arguments, if any. interface I {} type T1 = I ->T1 : T1 +>T1 : I // A union type directly depends on each of the constituent types. type T2 = T2 | string @@ -27,15 +27,15 @@ class C {} >C : C type T2_1 = T2_1[] | number ->T2_1 : T2_1 +>T2_1 : number | T2_1[] // An array type directly depends on its element type. type T3 = T3[] ->T3 : T3 +>T3 : T3[] // A tuple type directly depends on each of its element types. type T4 = [number, T4] ->T4 : T4 +>T4 : [number, T4] // A type query directly depends on the type of the referenced entity. var x: T5[] = [] @@ -50,7 +50,7 @@ class C1 {} >C1 : C1 type T6 = T7 | number ->T6 : T6 +>T6 : number | [string, T8[]] type T7 = typeof yy >T7 : [string, T8[]] @@ -60,22 +60,22 @@ var yy: [string, T8[]]; >yy : [string, T8[]] type T8 = C ->T8 : T8 +>T8 : C // legal cases type T9 = () => T9 ->T9 : T9 +>T9 : () => T9 type T10 = { x: T10 } | { new(v: T10): string } ->T10 : T10 +>T10 : { x: T10; } | (new (v: T10) => string) >x : T10 >v : T10 type T11 = T12[] ->T11 : T11 +>T11 : T12[] type T12 = [T13, string] ->T12 : T12 +>T12 : [{ x: T11; }, string] type T13 = typeof zz >T13 : { x: T11; } diff --git a/tests/baselines/reference/discriminableUnionWithIntersectedMembers.types b/tests/baselines/reference/discriminableUnionWithIntersectedMembers.types index 633d23c65c6fd..3cb79ee43ee15 100644 --- a/tests/baselines/reference/discriminableUnionWithIntersectedMembers.types +++ b/tests/baselines/reference/discriminableUnionWithIntersectedMembers.types @@ -1,7 +1,7 @@ === tests/cases/compiler/discriminableUnionWithIntersectedMembers.ts === // regression test for https://github.com/microsoft/TypeScript/issues/33243 type X = ->X : X +>X : ({ x: 'x'; y: number; } & { y: number; }) | ({ x: 'y'; y: number; z?: boolean; } & { y: number; }) | { x: 'x', y: number } & { y: number } >x : "x" @@ -24,7 +24,7 @@ const x: X = 4 as any as { x: 'x' | 'y', y: number }; >y : number type Y = ->Y : Y +>Y : { x: 'x'; y: number; } | { x: 'y'; y: number; z?: boolean; } | { x: 'x', y: number } >x : "x" diff --git a/tests/baselines/reference/discriminantElementAccessCheck.types b/tests/baselines/reference/discriminantElementAccessCheck.types index 357173b8a0f40..6b378468c83f5 100644 --- a/tests/baselines/reference/discriminantElementAccessCheck.types +++ b/tests/baselines/reference/discriminantElementAccessCheck.types @@ -1,6 +1,6 @@ === tests/cases/compiler/discriminantElementAccessCheck.ts === type U = TypeA | TypeB; ->U : U +>U : TypeA | TypeB interface TypeA { kind: 'A'; diff --git a/tests/baselines/reference/discriminantPropertyCheck.types b/tests/baselines/reference/discriminantPropertyCheck.types index 10d3b5f117c47..e93ccc20ac759 100644 --- a/tests/baselines/reference/discriminantPropertyCheck.types +++ b/tests/baselines/reference/discriminantPropertyCheck.types @@ -1,6 +1,6 @@ === tests/cases/compiler/discriminantPropertyCheck.ts === type Item = Item1 | Item2; ->Item : Item +>Item : Item1 | Item2 interface Base { bar: boolean; @@ -243,7 +243,7 @@ enum Types { Str = 1, Num = 2 } >2 : 2 type Instance = StrType | NumType; ->Instance : Instance +>Instance : StrType | NumType interface StrType { type: Types.Str; @@ -335,7 +335,7 @@ interface B { } type U = A | B; ->U : U +>U : A | B const u: U = {} as any; >u : U @@ -381,10 +381,10 @@ u.b && u.a && f(u.a, u.b); // Repro from #29012 type Additive = '+' | '-'; ->Additive : Additive +>Additive : "+" | "-" type Multiplicative = '*' | '/'; ->Multiplicative : Multiplicative +>Multiplicative : "*" | "/" interface AdditiveObj { key: Additive @@ -397,7 +397,7 @@ interface MultiplicativeObj { } type Obj = AdditiveObj | MultiplicativeObj ->Obj : Obj +>Obj : AdditiveObj | MultiplicativeObj export function foo(obj: Obj) { >foo : (obj: Obj) => void @@ -450,15 +450,15 @@ const enum BarEnum { } type UnionOfBar = TypeBar1 | TypeBar2; ->UnionOfBar : UnionOfBar +>UnionOfBar : TypeBar1 | TypeBar2 type TypeBar1 = { type: BarEnum.bar1 }; ->TypeBar1 : TypeBar1 +>TypeBar1 : { type: BarEnum.bar1; } >type : BarEnum.bar1 >BarEnum : any type TypeBar2 = { type: BarEnum.bar2 }; ->TypeBar2 : TypeBar2 +>TypeBar2 : { type: BarEnum.bar2; } >type : BarEnum.bar2 >BarEnum : any @@ -520,7 +520,7 @@ interface TypeB { } type Type = TypeA | TypeB; ->Type : Type +>Type : TypeA | TypeB declare function isType(x: unknown): x is Type; >isType : (x: unknown) => x is Type @@ -573,7 +573,7 @@ function DoesNotWork(data: unknown) { // Repro from #36777 type TestA = { ->TestA : TestA +>TestA : { type: 'testA'; bananas: 3; } type: 'testA'; >type : "testA" @@ -583,7 +583,7 @@ type TestA = { } type TestB = { ->TestB : TestB +>TestB : { type: 'testB'; apples: 5; } type: 'testB'; >type : "testB" @@ -593,10 +593,10 @@ type TestB = { } type AllTests = TestA | TestB; ->AllTests : AllTests +>AllTests : TestA | TestB type MapOfAllTests = Record; ->MapOfAllTests : MapOfAllTests +>MapOfAllTests : { [x: string]: AllTests; } const doTestingStuff = (mapOfTests: MapOfAllTests, ids: string[]) => { >doTestingStuff : (mapOfTests: MapOfAllTests, ids: string[]) => void diff --git a/tests/baselines/reference/discriminantPropertyInference.types b/tests/baselines/reference/discriminantPropertyInference.types index 2ebc6c6a373fe..333b93e0eb19a 100644 --- a/tests/baselines/reference/discriminantPropertyInference.types +++ b/tests/baselines/reference/discriminantPropertyInference.types @@ -2,7 +2,7 @@ // Repro from #41759 type DiscriminatorTrue = { ->DiscriminatorTrue : DiscriminatorTrue +>DiscriminatorTrue : { disc: true; cb: (x: string) => void; } disc: true; >disc : true @@ -14,7 +14,7 @@ type DiscriminatorTrue = { } type DiscriminatorFalse = { ->DiscriminatorFalse : DiscriminatorFalse +>DiscriminatorFalse : { disc?: false | undefined; cb: (x: number) => void; } disc?: false; >disc : false | undefined @@ -26,7 +26,7 @@ type DiscriminatorFalse = { } type Props = DiscriminatorTrue | DiscriminatorFalse; ->Props : Props +>Props : DiscriminatorTrue | DiscriminatorFalse declare function f(options: DiscriminatorTrue | DiscriminatorFalse): any; >f : (options: DiscriminatorTrue | DiscriminatorFalse) => any diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.types b/tests/baselines/reference/discriminantsAndNullOrUndefined.types index 46cb2095fb5eb..f1814dbe5e27c 100644 --- a/tests/baselines/reference/discriminantsAndNullOrUndefined.types +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.types @@ -8,7 +8,7 @@ interface B { kind: 'B'; } >kind : "B" type C = A | B | undefined; ->C : C +>C : A | B | undefined function never(_: never): never { >never : (_: never) => never diff --git a/tests/baselines/reference/discriminantsAndPrimitives.types b/tests/baselines/reference/discriminantsAndPrimitives.types index 6ad18446bf01f..07b07fdac0a52 100644 --- a/tests/baselines/reference/discriminantsAndPrimitives.types +++ b/tests/baselines/reference/discriminantsAndPrimitives.types @@ -142,7 +142,7 @@ const enum EnumTypeNode { } type NodeA = Disjunction | Pattern; ->NodeA : NodeA +>NodeA : Disjunction | Pattern interface NodeBase { type: NodeA["type"] diff --git a/tests/baselines/reference/discriminateObjectTypesOnly.types b/tests/baselines/reference/discriminateObjectTypesOnly.types index 27b686b4a67f3..59de23555e428 100644 --- a/tests/baselines/reference/discriminateObjectTypesOnly.types +++ b/tests/baselines/reference/discriminateObjectTypesOnly.types @@ -1,6 +1,6 @@ === tests/cases/compiler/discriminateObjectTypesOnly.ts === type Thing = number | object; ->Thing : Thing +>Thing : number | object const k: Thing = { toFixed: null }; // OK, satisfies object >k : Thing @@ -9,7 +9,7 @@ const k: Thing = { toFixed: null }; // OK, satisfies object >null : null type Thing2 = number | { toFixed: null } | object; ->Thing2 : Thing2 +>Thing2 : number | object | { toFixed: null; } >toFixed : null >null : null @@ -26,7 +26,7 @@ const h: Thing2 = { toString: null }; // OK, satisfies object >null : null type Thing3 = number | { toFixed: null, toString: undefined } | object; ->Thing3 : Thing3 +>Thing3 : number | object | { toFixed: null; toString: undefined; } >toFixed : null >null : null >toString : undefined diff --git a/tests/baselines/reference/discriminatedUnionErrorMessage.types b/tests/baselines/reference/discriminatedUnionErrorMessage.types index ca405c5e3dc3a..842b7c5f9b6f1 100644 --- a/tests/baselines/reference/discriminatedUnionErrorMessage.types +++ b/tests/baselines/reference/discriminatedUnionErrorMessage.types @@ -1,22 +1,22 @@ === tests/cases/compiler/discriminatedUnionErrorMessage.ts === type Square = { kind: "sq", size: number } ->Square : Square +>Square : { kind: "sq"; size: number; } >kind : "sq" >size : number type Rectangle = { kind: "rt", x: number, y: number } ->Rectangle : Rectangle +>Rectangle : { kind: "rt"; x: number; y: number; } >kind : "rt" >x : number >y : number type Circle = { kind: "cr", radius: number } ->Circle : Circle +>Circle : { kind: "cr"; radius: number; } >kind : "cr" >radius : number type Shape = ->Shape : Shape +>Shape : Square | Rectangle | Circle | Square | Rectangle diff --git a/tests/baselines/reference/discriminatedUnionJsxElement.types b/tests/baselines/reference/discriminatedUnionJsxElement.types index 54ca2b4268f54..4f7b5a1ccdd9c 100644 --- a/tests/baselines/reference/discriminatedUnionJsxElement.types +++ b/tests/baselines/reference/discriminatedUnionJsxElement.types @@ -31,7 +31,7 @@ function Menu } type IListItemData = { variant: ListItemVariant.Avatar; } | { variant: ListItemVariant.OneLine; }; ->IListItemData : IListItemData +>IListItemData : { variant: ListItemVariant.Avatar; } | { variant: ListItemVariant.OneLine; } >variant : ListItemVariant.Avatar >ListItemVariant : any >variant : ListItemVariant.OneLine diff --git a/tests/baselines/reference/discriminatedUnionTypes1.types b/tests/baselines/reference/discriminatedUnionTypes1.types index 7c8c6c48171ba..cec56bde34f1a 100644 --- a/tests/baselines/reference/discriminatedUnionTypes1.types +++ b/tests/baselines/reference/discriminatedUnionTypes1.types @@ -27,7 +27,7 @@ interface Circle { } type Shape = Square | Rectangle | Circle; ->Shape : Shape +>Shape : Square | Rectangle | Circle function area1(s: Shape) { >area1 : (s: Shape) => number @@ -248,7 +248,7 @@ function area4(s: Shape) { } type Message = ->Message : Message +>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } { kind: "A", x: string } | >kind : "A" diff --git a/tests/baselines/reference/discriminatedUnionTypes2.types b/tests/baselines/reference/discriminatedUnionTypes2.types index 695f0c3768f00..07250ba11fa66 100644 --- a/tests/baselines/reference/discriminatedUnionTypes2.types +++ b/tests/baselines/reference/discriminatedUnionTypes2.types @@ -242,7 +242,7 @@ function f20(carrier: DataCarrier) { // Repro from #28935 type Foo = { tag: true, x: number } | { tag: false, y: number } | { [x: string]: string }; ->Foo : Foo +>Foo : { tag: true; x: number; } | { tag: false; y: number; } | { [x: string]: string; } >tag : true >true : true >x : number @@ -292,7 +292,7 @@ function f31(foo: Foo) { // Repro from #33448 type a = { ->a : a +>a : { type: 'a'; data: string; } type: 'a', >type : "a" @@ -301,7 +301,7 @@ type a = { >data : string } type b = { ->b : b +>b : { type: 'b'; name: string; } type: 'b', >type : "b" @@ -310,7 +310,7 @@ type b = { >name : string } type c = { ->c : c +>c : { type: 'c'; other: string; } type: 'c', >type : "c" @@ -320,7 +320,7 @@ type c = { } type abc = a | b | c; ->abc : abc +>abc : a | b | c function f(problem: abc & (b | c)) { >f : (problem: abc & (b | c)) => void @@ -347,7 +347,7 @@ function f(problem: abc & (b | c)) { } type RuntimeValue = ->RuntimeValue : RuntimeValue +>RuntimeValue : { type: 'number'; value: number; } | { type: 'string'; value: string; } | { type: 'boolean'; value: boolean; } | { type: 'number', value: number } >type : "number" diff --git a/tests/baselines/reference/discriminatedUnionTypes3.types b/tests/baselines/reference/discriminatedUnionTypes3.types index 8c645a1773592..1b88a38aa1bab 100644 --- a/tests/baselines/reference/discriminatedUnionTypes3.types +++ b/tests/baselines/reference/discriminatedUnionTypes3.types @@ -2,7 +2,7 @@ // Repro from #44435 type Correct = { ->Correct : Correct +>Correct : { code: string; property: true; err: undefined; } code: string >code : string @@ -15,13 +15,13 @@ type Correct = { >err : undefined } type Err = { ->Err : Err +>Err : { err: `${string} is wrong!`; } err: `${string} is wrong!` >err : `${string} is wrong!` } type SomeReturnType = Correct | Err; ->SomeReturnType : SomeReturnType +>SomeReturnType : Correct | Err const example: SomeReturnType = {} as SomeReturnType; >example : SomeReturnType diff --git a/tests/baselines/reference/divergentAccessorsTypes1.types b/tests/baselines/reference/divergentAccessorsTypes1.types index be4ebc6243c3a..258492ff8717e 100644 --- a/tests/baselines/reference/divergentAccessorsTypes1.types +++ b/tests/baselines/reference/divergentAccessorsTypes1.types @@ -48,7 +48,7 @@ interface Test2 { } type Test3 = { ->Test3 : Test3 +>Test3 : { foo: string; bar: string | number; } get foo(): string; >foo : string diff --git a/tests/baselines/reference/doNotInferUnrelatedTypes.types b/tests/baselines/reference/doNotInferUnrelatedTypes.types index e3a9522721ae8..21a1f76d2eaf0 100644 --- a/tests/baselines/reference/doNotInferUnrelatedTypes.types +++ b/tests/baselines/reference/doNotInferUnrelatedTypes.types @@ -5,7 +5,7 @@ declare function dearray(ara: ReadonlyArray): T; >ara : readonly T[] type LiteralType = "foo" | "bar"; ->LiteralType : LiteralType +>LiteralType : "foo" | "bar" declare var alt: Array; >alt : LiteralType[] diff --git a/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types b/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types index 79862e0733069..587f32d6a195a 100644 --- a/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types +++ b/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types @@ -1,6 +1,6 @@ === tests/cases/compiler/doubleMixinConditionalTypeBaseClassWorks.ts === type Constructor = new (...args: any[]) => {}; ->Constructor : Constructor +>Constructor : new (...args: any[]) => {} >args : any[] const Mixin1 = (Base: C) => class extends Base { private _fooPrivate: {}; } diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 03b6b980f3c67..8a2a1387677af 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -45,7 +45,7 @@ export declare class T2 extends T1 { >T1 : T1 } export declare type T3 = { ->T3 : T3 +>T3 : { a: number; 1: string; [s0]: boolean; } [c0]: number; >[c0] : number @@ -135,7 +135,7 @@ namespace N { >T5 : T5 } export declare type T7 = { ->T7 : T7 +>T7 : { a: number; 1: string; [s0]: boolean; } [N.c2]: number; >[N.c2] : number @@ -204,7 +204,7 @@ declare class T10 extends T9 { >T9 : T9 } declare type T11 = { ->T11 : T11 +>T11 : { a: number; 1: string; [s0]: boolean; } [c4]: number; >[c4] : number @@ -249,7 +249,7 @@ declare class T14 extends T13 { >T13 : T13 } declare type T15 = { ->T15 : T15 +>T15 : { a: number; 1: string; [s0]: boolean; } a: number; >a : number diff --git a/tests/baselines/reference/dynamicNamesErrors.types b/tests/baselines/reference/dynamicNamesErrors.types index b4f44376af89b..0ae2e48638ebc 100644 --- a/tests/baselines/reference/dynamicNamesErrors.types +++ b/tests/baselines/reference/dynamicNamesErrors.types @@ -127,7 +127,7 @@ export class ClassMemberVisibility { } export type ObjectTypeVisibility = { ->ObjectTypeVisibility : ObjectTypeVisibility +>ObjectTypeVisibility : { [x]: number; [y](): number; } [x]: number; >[x] : number diff --git a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.errors.txt b/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.errors.txt deleted file mode 100644 index cabda9caa7e94..0000000000000 --- a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.errors.txt +++ /dev/null @@ -1,47 +0,0 @@ -tests/cases/compiler/index.ts(8,23): error TS1267: A type referenced in a decorated signature must be imported with 'import type' when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. -tests/cases/compiler/index.ts(14,8): error TS1267: A type referenced in a decorated signature must be imported with 'import type' when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. -tests/cases/compiler/index.ts(20,28): error TS1267: A type referenced in a decorated signature must be imported with 'import type' when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. - - -==== tests/cases/compiler/type1.ts (0 errors) ==== - interface T1 {} - export type { T1 } - -==== tests/cases/compiler/type2.ts (0 errors) ==== - export interface T2 {} - -==== tests/cases/compiler/class3.ts (0 errors) ==== - export class C3 {} - -==== tests/cases/compiler/index.ts (3 errors) ==== - import { T1 } from "./type1"; - import type { T2 } from "./type2"; - import { C3 } from "./class3"; - declare var EventListener: any; - - class HelloWorld { - @EventListener('1') - handleEvent1(event: T1) {} // Error - ~~ -!!! error TS1267: A type referenced in a decorated signature must be imported with 'import type' when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. -!!! related TS1376 tests/cases/compiler/index.ts:1:10: 'T1' was imported here. - - @EventListener('2') - handleEvent2(event: T2) {} // Ok - - @EventListener('1') - p1!: T1; // Error - ~~ -!!! error TS1267: A type referenced in a decorated signature must be imported with 'import type' when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. -!!! related TS1376 tests/cases/compiler/index.ts:1:10: 'T1' was imported here. - - @EventListener('2') - p2!: T2; // Ok - - @EventListener('3') - handleEvent3(event: C3): T1 { return undefined! } // Ok, Error - ~~ -!!! error TS1267: A type referenced in a decorated signature must be imported with 'import type' when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. -!!! related TS1376 tests/cases/compiler/index.ts:1:10: 'T1' was imported here. - } - \ No newline at end of file diff --git a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.js b/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.js deleted file mode 100644 index bb5e71383f494..0000000000000 --- a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.js +++ /dev/null @@ -1,99 +0,0 @@ -//// [tests/cases/compiler/emitDecoratorMetadata_isolatedModules.ts] //// - -//// [type1.ts] -interface T1 {} -export type { T1 } - -//// [type2.ts] -export interface T2 {} - -//// [class3.ts] -export class C3 {} - -//// [index.ts] -import { T1 } from "./type1"; -import type { T2 } from "./type2"; -import { C3 } from "./class3"; -declare var EventListener: any; - -class HelloWorld { - @EventListener('1') - handleEvent1(event: T1) {} // Error - - @EventListener('2') - handleEvent2(event: T2) {} // Ok - - @EventListener('1') - p1!: T1; // Error - - @EventListener('2') - p2!: T2; // Ok - - @EventListener('3') - handleEvent3(event: C3): T1 { return undefined! } // Ok, Error -} - - -//// [type1.js] -"use strict"; -exports.__esModule = true; -//// [type2.js] -"use strict"; -exports.__esModule = true; -//// [class3.js] -"use strict"; -exports.__esModule = true; -exports.C3 = void 0; -var C3 = /** @class */ (function () { - function C3() { - } - return C3; -}()); -exports.C3 = C3; -//// [index.js] -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -exports.__esModule = true; -var class3_1 = require("./class3"); -var HelloWorld = /** @class */ (function () { - function HelloWorld() { - } - HelloWorld.prototype.handleEvent1 = function (event) { }; // Error - HelloWorld.prototype.handleEvent2 = function (event) { }; // Ok - HelloWorld.prototype.handleEvent3 = function (event) { return undefined; }; // Ok, Error - __decorate([ - EventListener('1'), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", void 0) - ], HelloWorld.prototype, "handleEvent1"); - __decorate([ - EventListener('2'), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", void 0) - ], HelloWorld.prototype, "handleEvent2"); - __decorate([ - EventListener('1'), - __metadata("design:type", Object) - ], HelloWorld.prototype, "p1"); - __decorate([ - EventListener('2'), - __metadata("design:type", Object) - ], HelloWorld.prototype, "p2"); - __decorate([ - EventListener('3'), - __metadata("design:type", Function), - __metadata("design:paramtypes", [class3_1.C3]), - __metadata("design:returntype", Object) - ], HelloWorld.prototype, "handleEvent3"); - return HelloWorld; -}()); diff --git a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.symbols b/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.symbols deleted file mode 100644 index c957b1781e3ea..0000000000000 --- a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.symbols +++ /dev/null @@ -1,72 +0,0 @@ -=== tests/cases/compiler/type1.ts === -interface T1 {} ->T1 : Symbol(T1, Decl(type1.ts, 0, 0)) - -export type { T1 } ->T1 : Symbol(T1, Decl(type1.ts, 1, 13)) - -=== tests/cases/compiler/type2.ts === -export interface T2 {} ->T2 : Symbol(T2, Decl(type2.ts, 0, 0)) - -=== tests/cases/compiler/class3.ts === -export class C3 {} ->C3 : Symbol(C3, Decl(class3.ts, 0, 0)) - -=== tests/cases/compiler/index.ts === -import { T1 } from "./type1"; ->T1 : Symbol(T1, Decl(index.ts, 0, 8)) - -import type { T2 } from "./type2"; ->T2 : Symbol(T2, Decl(index.ts, 1, 13)) - -import { C3 } from "./class3"; ->C3 : Symbol(C3, Decl(index.ts, 2, 8)) - -declare var EventListener: any; ->EventListener : Symbol(EventListener, Decl(index.ts, 3, 11)) - -class HelloWorld { ->HelloWorld : Symbol(HelloWorld, Decl(index.ts, 3, 31)) - - @EventListener('1') ->EventListener : Symbol(EventListener, Decl(index.ts, 3, 11)) - - handleEvent1(event: T1) {} // Error ->handleEvent1 : Symbol(HelloWorld.handleEvent1, Decl(index.ts, 5, 18)) ->event : Symbol(event, Decl(index.ts, 7, 15)) ->T1 : Symbol(T1, Decl(index.ts, 0, 8)) - - @EventListener('2') ->EventListener : Symbol(EventListener, Decl(index.ts, 3, 11)) - - handleEvent2(event: T2) {} // Ok ->handleEvent2 : Symbol(HelloWorld.handleEvent2, Decl(index.ts, 7, 28)) ->event : Symbol(event, Decl(index.ts, 10, 15)) ->T2 : Symbol(T2, Decl(index.ts, 1, 13)) - - @EventListener('1') ->EventListener : Symbol(EventListener, Decl(index.ts, 3, 11)) - - p1!: T1; // Error ->p1 : Symbol(HelloWorld.p1, Decl(index.ts, 10, 28)) ->T1 : Symbol(T1, Decl(index.ts, 0, 8)) - - @EventListener('2') ->EventListener : Symbol(EventListener, Decl(index.ts, 3, 11)) - - p2!: T2; // Ok ->p2 : Symbol(HelloWorld.p2, Decl(index.ts, 13, 10)) ->T2 : Symbol(T2, Decl(index.ts, 1, 13)) - - @EventListener('3') ->EventListener : Symbol(EventListener, Decl(index.ts, 3, 11)) - - handleEvent3(event: C3): T1 { return undefined! } // Ok, Error ->handleEvent3 : Symbol(HelloWorld.handleEvent3, Decl(index.ts, 16, 10)) ->event : Symbol(event, Decl(index.ts, 19, 15)) ->C3 : Symbol(C3, Decl(index.ts, 2, 8)) ->T1 : Symbol(T1, Decl(index.ts, 0, 8)) ->undefined : Symbol(undefined) -} - diff --git a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.types b/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.types deleted file mode 100644 index 0048771bb4eac..0000000000000 --- a/tests/baselines/reference/emitDecoratorMetadata_isolatedModules.types +++ /dev/null @@ -1,74 +0,0 @@ -=== tests/cases/compiler/type1.ts === -interface T1 {} -export type { T1 } ->T1 : T1 - -=== tests/cases/compiler/type2.ts === -export interface T2 {} -No type information for this code. -No type information for this code.=== tests/cases/compiler/class3.ts === -export class C3 {} ->C3 : C3 - -=== tests/cases/compiler/index.ts === -import { T1 } from "./type1"; ->T1 : any - -import type { T2 } from "./type2"; ->T2 : T2 - -import { C3 } from "./class3"; ->C3 : typeof C3 - -declare var EventListener: any; ->EventListener : any - -class HelloWorld { ->HelloWorld : HelloWorld - - @EventListener('1') ->EventListener('1') : any ->EventListener : any ->'1' : "1" - - handleEvent1(event: T1) {} // Error ->handleEvent1 : (event: T1) => void ->event : T1 - - @EventListener('2') ->EventListener('2') : any ->EventListener : any ->'2' : "2" - - handleEvent2(event: T2) {} // Ok ->handleEvent2 : (event: T2) => void ->event : T2 - - @EventListener('1') ->EventListener('1') : any ->EventListener : any ->'1' : "1" - - p1!: T1; // Error ->p1 : T1 - - @EventListener('2') ->EventListener('2') : any ->EventListener : any ->'2' : "2" - - p2!: T2; // Ok ->p2 : T2 - - @EventListener('3') ->EventListener('3') : any ->EventListener : any ->'3' : "3" - - handleEvent3(event: C3): T1 { return undefined! } // Ok, Error ->handleEvent3 : (event: C3) => T1 ->event : C3 ->undefined! : undefined ->undefined : undefined -} - diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js similarity index 100% rename from tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js rename to tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js diff --git a/tests/baselines/reference/enumLiteralTypes1.types b/tests/baselines/reference/enumLiteralTypes1.types index b3541381043ad..0314a6d807738 100644 --- a/tests/baselines/reference/enumLiteralTypes1.types +++ b/tests/baselines/reference/enumLiteralTypes1.types @@ -6,17 +6,17 @@ const enum Choice { Unknown, Yes, No }; >No : Choice.No type YesNo = Choice.Yes | Choice.No; ->YesNo : YesNo +>YesNo : Choice.Yes | Choice.No >Choice : any >Choice : any type NoYes = Choice.No | Choice.Yes; ->NoYes : NoYes +>NoYes : Choice.Yes | Choice.No >Choice : any >Choice : any type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; ->UnknownYesNo : UnknownYesNo +>UnknownYesNo : Choice >Choice : any >Choice : any >Choice : any @@ -344,7 +344,7 @@ function f13(x: UnknownYesNo) { } type Item = ->Item : Item +>Item : { kind: Choice.Yes; a: string; } | { kind: Choice.No; b: string; } { kind: Choice.Yes, a: string } | >kind : Choice.Yes diff --git a/tests/baselines/reference/enumLiteralTypes2.types b/tests/baselines/reference/enumLiteralTypes2.types index d724072fc1b5e..b5a887094c862 100644 --- a/tests/baselines/reference/enumLiteralTypes2.types +++ b/tests/baselines/reference/enumLiteralTypes2.types @@ -6,17 +6,17 @@ const enum Choice { Unknown, Yes, No }; >No : Choice.No type YesNo = Choice.Yes | Choice.No; ->YesNo : YesNo +>YesNo : Choice.Yes | Choice.No >Choice : any >Choice : any type NoYes = Choice.No | Choice.Yes; ->NoYes : NoYes +>NoYes : Choice.Yes | Choice.No >Choice : any >Choice : any type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; ->UnknownYesNo : UnknownYesNo +>UnknownYesNo : Choice >Choice : any >Choice : any >Choice : any @@ -344,7 +344,7 @@ function f13(x: UnknownYesNo) { } type Item = ->Item : Item +>Item : { kind: Choice.Yes; a: string; } | { kind: Choice.No; b: string; } { kind: Choice.Yes, a: string } | >kind : Choice.Yes diff --git a/tests/baselines/reference/enumLiteralTypes3.types b/tests/baselines/reference/enumLiteralTypes3.types index 04b5ceb0697cf..d420a1786462b 100644 --- a/tests/baselines/reference/enumLiteralTypes3.types +++ b/tests/baselines/reference/enumLiteralTypes3.types @@ -10,17 +10,17 @@ type Yes = Choice.Yes; >Choice : any type YesNo = Choice.Yes | Choice.No; ->YesNo : YesNo +>YesNo : Choice.Yes | Choice.No >Choice : any >Choice : any type NoYes = Choice.No | Choice.Yes; ->NoYes : NoYes +>NoYes : Choice.Yes | Choice.No >Choice : any >Choice : any type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; ->UnknownYesNo : UnknownYesNo +>UnknownYesNo : Choice >Choice : any >Choice : any >Choice : any diff --git a/tests/baselines/reference/enumLiteralUnionNotWidened.types b/tests/baselines/reference/enumLiteralUnionNotWidened.types index 87443fbd54906..1446b2a56ad58 100644 --- a/tests/baselines/reference/enumLiteralUnionNotWidened.types +++ b/tests/baselines/reference/enumLiteralUnionNotWidened.types @@ -15,11 +15,11 @@ enum B { foo = "foo", bar = "bar" }; >"bar" : "bar" type C = A | B.foo; ->C : C +>C : A | B.foo >B : any type D = A | "foo"; ->D : D +>D : A | "foo" class List >List : List diff --git a/tests/baselines/reference/errorForUsingPropertyOfTypeAsType01.types b/tests/baselines/reference/errorForUsingPropertyOfTypeAsType01.types index 55a7d345f7189..6b0d4e1f32bc5 100644 --- a/tests/baselines/reference/errorForUsingPropertyOfTypeAsType01.types +++ b/tests/baselines/reference/errorForUsingPropertyOfTypeAsType01.types @@ -45,7 +45,7 @@ namespace Test3 { >Test3 : typeof Test3 export type Foo = { ->Foo : Foo +>Foo : { bar: string; } bar: string; >bar : string @@ -67,7 +67,7 @@ namespace Test4 { >Test4 : typeof Test4 export type Foo = { bar: number } ->Foo : Foo +>Foo : { bar: number; } | { bar: string; } >bar : number | { bar: string } @@ -89,7 +89,7 @@ namespace Test5 { >Test5 : typeof Test5 export type Foo = { bar: number } ->Foo : Foo +>Foo : { bar: number; } | { wat: string; } >bar : number | { wat: string } diff --git a/tests/baselines/reference/errorMessageOnIntersectionsWithDiscriminants01.types b/tests/baselines/reference/errorMessageOnIntersectionsWithDiscriminants01.types index 4c532de4b272e..5222b5566f853 100644 --- a/tests/baselines/reference/errorMessageOnIntersectionsWithDiscriminants01.types +++ b/tests/baselines/reference/errorMessageOnIntersectionsWithDiscriminants01.types @@ -1,17 +1,17 @@ === tests/cases/compiler/errorMessageOnIntersectionsWithDiscriminants01.ts === export type Common = { test: true } | { test: false }; ->Common : Common +>Common : { test: true; } | { test: false; } >test : true >true : true >test : false >false : false export type A = Common & { foo: 1 }; ->A : A +>A : Common & { foo: 1; } >foo : 1 export type B = Common & { bar: 1 }; ->B : B +>B : Common & { bar: 1; } >bar : 1 declare const a: A; diff --git a/tests/baselines/reference/errorsOnUnionsOfOverlappingObjects01.types b/tests/baselines/reference/errorsOnUnionsOfOverlappingObjects01.types index 1e9b1b8c5ef50..1a705d7973325 100644 --- a/tests/baselines/reference/errorsOnUnionsOfOverlappingObjects01.types +++ b/tests/baselines/reference/errorsOnUnionsOfOverlappingObjects01.types @@ -93,7 +93,7 @@ interface Platypus { platypus: any } >platypus : any type ExoticAnimal = ->ExoticAnimal : ExoticAnimal +>ExoticAnimal : CatDog | ManBearPig | Platypus | CatDog | ManBearPig diff --git a/tests/baselines/reference/es2022IntlAPIs.symbols b/tests/baselines/reference/es2022IntlAPIs.symbols index 939c6b383a5f8..914f9c93a853c 100644 --- a/tests/baselines/reference/es2022IntlAPIs.symbols +++ b/tests/baselines/reference/es2022IntlAPIs.symbols @@ -11,7 +11,7 @@ for (const zoneName of timezoneNames) { var formatter = new Intl.DateTimeFormat('en-US', { >formatter : Symbol(formatter, Decl(es2022IntlAPIs.ts, 3, 5)) >Intl.DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) ->Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 1 more) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more) >DateTimeFormat : Symbol(Intl.DateTimeFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --)) timeZone: 'America/Los_Angeles', diff --git a/tests/baselines/reference/eventEmitterPatternWithRecordOfFunction.types b/tests/baselines/reference/eventEmitterPatternWithRecordOfFunction.types index 37c9eaacf7a33..61e81fb65a711 100644 --- a/tests/baselines/reference/eventEmitterPatternWithRecordOfFunction.types +++ b/tests/baselines/reference/eventEmitterPatternWithRecordOfFunction.types @@ -11,7 +11,7 @@ type Args = F extends (...args: infer A) => void ? A : never; >args : A type EventMap = Record; ->EventMap : EventMap +>EventMap : { [x: string]: Function; } interface B extends A { emit(event: Event, ...args: Args): boolean; diff --git a/tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.types b/tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.types index 1f5d85b10a5b4..2c5b07e591444 100644 --- a/tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.types +++ b/tests/baselines/reference/excessPropertyCheckWithMultipleDiscriminants.types @@ -33,7 +33,7 @@ interface Bool extends Base { } type Primitive = Int | Float | Str | Bool; ->Primitive : Primitive +>Primitive : Int | Float | Str | Bool const foo: Primitive = { >foo : Primitive @@ -58,7 +58,7 @@ const foo: Primitive = { type DisjointDiscriminants = { p1: 'left'; p2: true; p3: number } | { p1: 'right'; p2: false; p4: string } | { p1: 'left'; p2: boolean }; ->DisjointDiscriminants : DisjointDiscriminants +>DisjointDiscriminants : { p1: 'left'; p2: true; p3: number; } | { p1: 'right'; p2: false; p4: string; } | { p1: 'left'; p2: boolean; } >p1 : "left" >p2 : true >true : true diff --git a/tests/baselines/reference/excessPropertyCheckWithUnions.types b/tests/baselines/reference/excessPropertyCheckWithUnions.types index 1a8cc69eaee08..2b012e13eb14c 100644 --- a/tests/baselines/reference/excessPropertyCheckWithUnions.types +++ b/tests/baselines/reference/excessPropertyCheckWithUnions.types @@ -1,6 +1,6 @@ === tests/cases/compiler/excessPropertyCheckWithUnions.ts === type ADT = { ->ADT : ADT +>ADT : { tag: "A"; a1: string; } | { tag: "D"; d20: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20; } | { tag: "T"; } tag: "A", >tag : "A" @@ -44,7 +44,7 @@ wrong = { tag: "D" } >"D" : "D" type Ambiguous = { ->Ambiguous : Ambiguous +>Ambiguous : { tag: "A"; x: string; } | { tag: "A"; y: number; } | { tag: "B"; z: boolean; } | { tag: "C"; } tag: "A", >tag : "A" @@ -146,7 +146,7 @@ amb = { tag: "A", z: true } >true : true type Overlapping = ->Overlapping : Overlapping +>Overlapping : { a: 1; b: 1; first: string; } | { a: 2; second: string; } | { b: 3; third: string; } | { a: 1, b: 1, first: string } >a : 1 @@ -220,16 +220,16 @@ t0 = t2 // Nested excess property checks work with discriminated unions type AN = { a: string } | { c: string } ->AN : AN +>AN : { a: string; } | { c: string; } >a : string >c : string type BN = { b: string } ->BN : BN +>BN : { b: string; } >b : string type AB = { kind: "A", n: AN } | { kind: "B", n: BN } ->AB : AB +>AB : { kind: "A"; n: AN; } | { kind: "B"; n: BN; } >kind : "A" >n : AN >kind : "B" @@ -280,18 +280,18 @@ const abac: AB = { // Excess property checks must match all discriminable properties type Button = { tag: 'button'; type?: 'submit'; }; ->Button : Button +>Button : { tag: 'button'; type?: "submit" | undefined; } >tag : "button" >type : "submit" | undefined type Anchor = { tag: 'a'; type?: string; href: string }; ->Anchor : Anchor +>Anchor : { tag: 'a'; type?: string | undefined; href: string; } >tag : "a" >type : string | undefined >href : string type Union = Button | Anchor; ->Union : Union +>Union : Button | Anchor const obj: Union = { >obj : Union @@ -331,7 +331,7 @@ interface NumberKeys { } type ObjectDataSpecification = StringKeys | NumberKeys; ->ObjectDataSpecification : ObjectDataSpecification +>ObjectDataSpecification : StringKeys | NumberKeys const dataSpecification: ObjectDataSpecification = { // Error @@ -381,7 +381,7 @@ interface I3 extends Record { } type Properties = ->Properties : Properties +>Properties : I1 | I2 | I3 | { [key: string]: never; } | { [key: string]: never } >key : string diff --git a/tests/baselines/reference/excessPropertyChecksWithNestedIntersections.types b/tests/baselines/reference/excessPropertyChecksWithNestedIntersections.types index 29019339fa6a7..9e9ef82d54d0a 100644 --- a/tests/baselines/reference/excessPropertyChecksWithNestedIntersections.types +++ b/tests/baselines/reference/excessPropertyChecksWithNestedIntersections.types @@ -17,7 +17,7 @@ interface C { } type D = B & C; ->D : D +>D : B & C let a: B = { a: { x: 'hello' } }; // ok >a : B @@ -80,7 +80,7 @@ let f: D = { a: { x: 'hello', y: 2 }, c: 5 }; // error - y does not exist in typ // https://github.com/Microsoft/TypeScript/issues/18075 export type MyType = { id: number; } & { name: string; } & { photo: { id: number; } & { url: string; } } ->MyType : MyType +>MyType : { id: number; } & { name: string; } & { photo: { id: number;} & { url: string;}; } >id : number >name : string >photo : { id: number; } & { url: string; } diff --git a/tests/baselines/reference/excessPropertyErrorForFunctionTypes.types b/tests/baselines/reference/excessPropertyErrorForFunctionTypes.types index 9792a38a6612e..5bde8cd170004 100644 --- a/tests/baselines/reference/excessPropertyErrorForFunctionTypes.types +++ b/tests/baselines/reference/excessPropertyErrorForFunctionTypes.types @@ -1,9 +1,9 @@ === tests/cases/compiler/excessPropertyErrorForFunctionTypes.ts === type FunctionType = () => any; ->FunctionType : FunctionType +>FunctionType : () => any type DoesntWork = { a: number, c: number } | FunctionType; ->DoesntWork : DoesntWork +>DoesntWork : { a: number; c: number; } | FunctionType >a : number >c : number diff --git a/tests/baselines/reference/excessiveStackDepthFlatArray.types b/tests/baselines/reference/excessiveStackDepthFlatArray.types index ae346a034fa67..d84f300a5f7e8 100644 --- a/tests/baselines/reference/excessiveStackDepthFlatArray.types +++ b/tests/baselines/reference/excessiveStackDepthFlatArray.types @@ -30,17 +30,17 @@ declare namespace React { >children : ReactNode } type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; ->ReactNode : ReactNode +>ReactNode : boolean | ReactText | ReactFragment >null : null type ReactText = string | number; ->ReactText : ReactText +>ReactText : string | number type ReactChild = ReactText; >ReactChild : ReactText type ReactFragment = {} | ReactNodeArray; ->ReactFragment : ReactFragment +>ReactFragment : {} | ReactNodeArray interface ReactNodeArray extends Array {} } diff --git a/tests/baselines/reference/excessivelyLargeTupleSpread.types b/tests/baselines/reference/excessivelyLargeTupleSpread.types index 5e1e63a8968f7..9c8c55e22fcf4 100644 --- a/tests/baselines/reference/excessivelyLargeTupleSpread.types +++ b/tests/baselines/reference/excessivelyLargeTupleSpread.types @@ -10,7 +10,7 @@ type A = BuildTuple<3> >A : any type T0 = [any]; ->T0 : T0 +>T0 : [any] type T1 = [...T0, ...T0]; >T1 : [any, any] diff --git a/tests/baselines/reference/exhaustiveSwitchStatements1.types b/tests/baselines/reference/exhaustiveSwitchStatements1.types index 4944989ed1d6d..6a74aa70549fa 100644 --- a/tests/baselines/reference/exhaustiveSwitchStatements1.types +++ b/tests/baselines/reference/exhaustiveSwitchStatements1.types @@ -155,7 +155,7 @@ interface Triangle { kind: "triangle"; side: number; } >side : number type Shape = Square | Rectangle | Circle | Triangle; ->Shape : Shape +>Shape : Square | Rectangle | Circle | Triangle function area(s: Shape): number { >area : (s: Shape) => number @@ -481,7 +481,7 @@ interface Circle2 { } type Shape2 = Square2 | Circle2; ->Shape2 : Shape2 +>Shape2 : Square2 | Circle2 function withDefault(s1: Shape2, s2: Shape2): string { >withDefault : (s1: Shape2, s2: Shape2) => string @@ -665,7 +665,7 @@ function foo() { // Repro from #35070 type O = { ->O : O +>O : { a: number; b: number; } a: number, >a : number @@ -675,7 +675,7 @@ type O = { }; type K = keyof O | 'c'; ->K : K +>K : keyof O | "c" function ff(o: O, k: K) { >ff : (o: O, k: K) => number @@ -706,7 +706,7 @@ function ff(o: O, k: K) { // Repro from #35431 type A = { kind: "abc" } | { kind: "def" }; ->A : A +>A : { kind: "abc"; } | { kind: "def"; } >kind : "abc" >kind : "def" diff --git a/tests/baselines/reference/exportDeclaration_moduleSpecifier-isolatedModules.types b/tests/baselines/reference/exportDeclaration_moduleSpecifier-isolatedModules.types index 78d90f12023c3..2bf0be5f3dd08 100644 --- a/tests/baselines/reference/exportDeclaration_moduleSpecifier-isolatedModules.types +++ b/tests/baselines/reference/exportDeclaration_moduleSpecifier-isolatedModules.types @@ -1,6 +1,6 @@ === /a.ts === export type A = {}; ->A : A +>A : {} === /b.ts === export type { A } from './a'; // should not error, but would without `type` diff --git a/tests/baselines/reference/exportDefaultExpressionComments.js b/tests/baselines/reference/exportDefaultExpressionComments.js new file mode 100644 index 0000000000000..c3a9bb61da611 --- /dev/null +++ b/tests/baselines/reference/exportDefaultExpressionComments.js @@ -0,0 +1,22 @@ +//// [exportDefaultExpressionComments.ts] +/** + * JSDoc Comments + */ +export default null + + +//// [exportDefaultExpressionComments.js] +"use strict"; +exports.__esModule = true; +/** + * JSDoc Comments + */ +exports["default"] = null; + + +//// [exportDefaultExpressionComments.d.ts] +/** + * JSDoc Comments + */ +declare const _default: any; +export default _default; diff --git a/tests/baselines/reference/exportDefaultExpressionComments.symbols b/tests/baselines/reference/exportDefaultExpressionComments.symbols new file mode 100644 index 0000000000000..a3a94331a56cd --- /dev/null +++ b/tests/baselines/reference/exportDefaultExpressionComments.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts === +/** +No type information for this code. * JSDoc Comments +No type information for this code. */ +No type information for this code.export default null +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultExpressionComments.types b/tests/baselines/reference/exportDefaultExpressionComments.types new file mode 100644 index 0000000000000..012b8d32555ff --- /dev/null +++ b/tests/baselines/reference/exportDefaultExpressionComments.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/declarationEmit/exportDefaultExpressionComments.ts === +/** + * JSDoc Comments + */ +export default null +>null : null + diff --git a/tests/baselines/reference/exportDefaultTypeAndClass.types b/tests/baselines/reference/exportDefaultTypeAndClass.types index 273a650257c5e..f6a7969aca11f 100644 --- a/tests/baselines/reference/exportDefaultTypeAndClass.types +++ b/tests/baselines/reference/exportDefaultTypeAndClass.types @@ -3,7 +3,7 @@ export default class Foo {} >Foo : Foo type Bar = {} ->Bar : Bar +>Bar : {} export default Bar >Bar : Bar diff --git a/tests/baselines/reference/exportDefaultTypeAndFunctionOverloads.types b/tests/baselines/reference/exportDefaultTypeAndFunctionOverloads.types index c014cddfa250e..e6b1cc80726fe 100644 --- a/tests/baselines/reference/exportDefaultTypeAndFunctionOverloads.types +++ b/tests/baselines/reference/exportDefaultTypeAndFunctionOverloads.types @@ -15,7 +15,7 @@ export default function foo(value: string | number): string | number { >1 : 1 } type Foo = {} ->Foo : Foo +>Foo : {} export default Foo >Foo : Foo diff --git a/tests/baselines/reference/exportDefaultTypeClassAndValue.types b/tests/baselines/reference/exportDefaultTypeClassAndValue.types index 2896db94a5ebb..de77a17902c18 100644 --- a/tests/baselines/reference/exportDefaultTypeClassAndValue.types +++ b/tests/baselines/reference/exportDefaultTypeClassAndValue.types @@ -10,7 +10,7 @@ export default class Foo {} >Foo : foo type Bar = {} ->Bar : Bar +>Bar : {} export default Bar >Bar : Bar diff --git a/tests/baselines/reference/exportNamespaceDeclarationRetainsVisibility.types b/tests/baselines/reference/exportNamespaceDeclarationRetainsVisibility.types index 69422a8458c0f..d500ed29a3529 100644 --- a/tests/baselines/reference/exportNamespaceDeclarationRetainsVisibility.types +++ b/tests/baselines/reference/exportNamespaceDeclarationRetainsVisibility.types @@ -11,7 +11,7 @@ namespace X { } export type C = A | B; ->C : C +>C : A | B } export = X; diff --git a/tests/baselines/reference/flowControlTypeGuardThenSwitch.types b/tests/baselines/reference/flowControlTypeGuardThenSwitch.types index 807a322073bd6..e197a80e454f6 100644 --- a/tests/baselines/reference/flowControlTypeGuardThenSwitch.types +++ b/tests/baselines/reference/flowControlTypeGuardThenSwitch.types @@ -33,7 +33,7 @@ interface B extends Base { } type Both = A | B; ->Both : Both +>Both : A | B function isBoth(x: Base): x is Both { >isBoth : (x: Base) => x is Both diff --git a/tests/baselines/reference/for-of58.types b/tests/baselines/reference/for-of58.types index f188378dfcec6..5a3470b45fb35 100644 --- a/tests/baselines/reference/for-of58.types +++ b/tests/baselines/reference/for-of58.types @@ -1,10 +1,10 @@ === tests/cases/conformance/es6/for-ofStatements/for-of58.ts === type X = { x: 'x' }; ->X : X +>X : { x: 'x'; } >x : "x" type Y = { y: 'y' }; ->Y : Y +>Y : { y: 'y'; } >y : "y" declare const arr: X[] & Y[]; diff --git a/tests/baselines/reference/forOfStringConstituents.types b/tests/baselines/reference/forOfStringConstituents.types index c895f3b022cc4..da3427aeb6843 100644 --- a/tests/baselines/reference/forOfStringConstituents.types +++ b/tests/baselines/reference/forOfStringConstituents.types @@ -14,10 +14,10 @@ interface D { x: 3; } >x : 3 type AB = A | B; ->AB : AB +>AB : A | B type CD = C | D; ->CD : CD +>CD : C | D declare let x: AB, y: CD; >x : AB diff --git a/tests/baselines/reference/formatToPartsBigInt.symbols b/tests/baselines/reference/formatToPartsBigInt.symbols index 41d4f83b1d989..1cf2f6000f551 100644 --- a/tests/baselines/reference/formatToPartsBigInt.symbols +++ b/tests/baselines/reference/formatToPartsBigInt.symbols @@ -5,14 +5,14 @@ new Intl.NumberFormat("fr").formatToParts(3000n); >new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) >Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) ->Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 3 more) >NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) >formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) new Intl.NumberFormat("fr").formatToParts(BigInt(123)); >new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) >Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) ->Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more) +>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 3 more) >NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --)) >formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --)) >BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --)) diff --git a/tests/baselines/reference/forwardRefInTypeDeclaration.types b/tests/baselines/reference/forwardRefInTypeDeclaration.types index de487ec372c6a..a6c59cbd4036a 100644 --- a/tests/baselines/reference/forwardRefInTypeDeclaration.types +++ b/tests/baselines/reference/forwardRefInTypeDeclaration.types @@ -19,7 +19,7 @@ const s2 = "x"; // or in a type definition type Foo3 = { [s3]: number; } ->Foo3 : Foo3 +>Foo3 : { x: number; } >[s3] : number >s3 : "x" diff --git a/tests/baselines/reference/functionCallOnConstrainedTypeVariable.types b/tests/baselines/reference/functionCallOnConstrainedTypeVariable.types index fb0318f14ddd3..b5734ef468eb0 100644 --- a/tests/baselines/reference/functionCallOnConstrainedTypeVariable.types +++ b/tests/baselines/reference/functionCallOnConstrainedTypeVariable.types @@ -2,7 +2,7 @@ // Repro from #20196 type A = { ->A : A +>A : { a: (x: number) => string; } a: (x: number) => string >a : (x: number) => string @@ -10,7 +10,7 @@ type A = { }; type B = { ->B : B +>B : { a: (x: boolean) => string; } a: (x: boolean) => string >a : (x: boolean) => string diff --git a/tests/baselines/reference/genericContextualTypes1.types b/tests/baselines/reference/genericContextualTypes1.types index f617b827ee2c6..d8bebed28bf9f 100644 --- a/tests/baselines/reference/genericContextualTypes1.types +++ b/tests/baselines/reference/genericContextualTypes1.types @@ -236,7 +236,7 @@ const f40: (b: B, a: A) => [A, B] = flip(zip); // Repro from #16293 type fn = (a: A) => A; ->fn : fn +>fn : (a: A) => A >a : A const fn: fn = a => a; diff --git a/tests/baselines/reference/genericDefaultsErrors.types b/tests/baselines/reference/genericDefaultsErrors.types index 2cd4d83c52732..312e130271566 100644 --- a/tests/baselines/reference/genericDefaultsErrors.types +++ b/tests/baselines/reference/genericDefaultsErrors.types @@ -70,10 +70,10 @@ type i09t01 = i09<1>; // error >i09t01 : any type i09t02 = i09<1, 2>; // ok ->i09t02 : i09t02 +>i09t02 : i09<1, 2, number> type i09t03 = i09<1, 2, 3>; // ok ->i09t03 : i09t03 +>i09t03 : i09<1, 2, 3> type i09t04 = i09<1, 2, 3, 4>; // error >i09t04 : any diff --git a/tests/baselines/reference/genericFunctionInference1.types b/tests/baselines/reference/genericFunctionInference1.types index 9ce0b1b2b24bb..9dd28cea1a72e 100644 --- a/tests/baselines/reference/genericFunctionInference1.types +++ b/tests/baselines/reference/genericFunctionInference1.types @@ -801,14 +801,14 @@ const fn20 = pipe((_a?: {}) => 1); >fn20 : (_a?: {} | undefined) => number >pipe((_a?: {}) => 1) : (_a?: {} | undefined) => number >pipe : { (ab: (...args: A) => B): (...args: A) => B; (ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; (ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; } ->(_a?: {}) => 1 : (_a?: {} | undefined) => number +>(_a?: {}) => 1 : (_a?: {}) => number >_a : {} | undefined >1 : 1 // #29904.3 type Fn = (n: number) => number; ->Fn : Fn +>Fn : (n: number) => number >n : number const fn30: Fn = pipe( @@ -968,7 +968,7 @@ const fn62 = pipe( // Repro from #30297 declare function foo2(fn: T, a?: U, b?: U): [T, U]; ->foo2 : (fn: T, a?: U | undefined, b?: U | undefined) => [T, U] +>foo2 : (fn: T, a?: U, b?: U) => [T, U] >fn : T >a : U | undefined >b : U | undefined diff --git a/tests/baselines/reference/genericFunctionInference2.types b/tests/baselines/reference/genericFunctionInference2.types index 85208d6fee42c..79fd0d14fd02c 100644 --- a/tests/baselines/reference/genericFunctionInference2.types +++ b/tests/baselines/reference/genericFunctionInference2.types @@ -10,7 +10,7 @@ declare function combineReducers(reducers: { [K in keyof S]: Reducer }) >reducers : { [K in keyof S]: Reducer; } type MyState = { combined: { foo: number } }; ->MyState : MyState +>MyState : { combined: { foo: number;}; } >combined : { foo: number; } >foo : number @@ -54,7 +54,7 @@ declare function withH(handlerCreators: HandleCreatorsFactory): U; >handlerCreators : HandleCreatorsFactory type Props = { out: number } ->Props : Props +>Props : { out: number; } >out : number type HandleCreatorsFactory = (initialProps: T) => { [P in keyof U]: (props: T) => U[P] }; diff --git a/tests/baselines/reference/genericObjectRest.types b/tests/baselines/reference/genericObjectRest.types index a10fc4d25c870..48a0ada2e7176 100644 --- a/tests/baselines/reference/genericObjectRest.types +++ b/tests/baselines/reference/genericObjectRest.types @@ -88,7 +88,7 @@ function f3(obj: T, k1: K1, k2: K2) { } type Item = { a: string, b: number, c: boolean }; ->Item : Item +>Item : { a: string; b: number; c: boolean; } >a : string >b : number >c : boolean diff --git a/tests/baselines/reference/genericObjectSpreadResultInSwitch.types b/tests/baselines/reference/genericObjectSpreadResultInSwitch.types index 4c9ca429daa37..40505e8bbf536 100644 --- a/tests/baselines/reference/genericObjectSpreadResultInSwitch.types +++ b/tests/baselines/reference/genericObjectSpreadResultInSwitch.types @@ -1,6 +1,6 @@ === tests/cases/compiler/genericObjectSpreadResultInSwitch.ts === type Params = { ->Params : Params +>Params : { foo: string; } & ({ tag: 'a'; type: number; } | { tag: 'b'; type: string; }) foo: string; >foo : string diff --git a/tests/baselines/reference/genericRestParameters1.types b/tests/baselines/reference/genericRestParameters1.types index 1e45a3c86621e..cbc4e9410755c 100644 --- a/tests/baselines/reference/genericRestParameters1.types +++ b/tests/baselines/reference/genericRestParameters1.types @@ -570,7 +570,7 @@ f23(); >f23 : () => string[] declare const g20: (x: number, y?: string, z?: boolean) => string[]; ->g20 : (x: number, y?: string | undefined, z?: boolean | undefined) => string[] +>g20 : (x: number, y?: string, z?: boolean) => string[] >x : number >y : string | undefined >z : boolean | undefined @@ -704,7 +704,7 @@ type T09 = Parameters; >T09 : never type Record1 = { ->Record1 : Record1 +>Record1 : { move: [number, 'left' | 'right']; jump: [number, 'up' | 'down']; stop: string; done: []; } move: [number, 'left' | 'right']; >move : [number, "left" | "right"] diff --git a/tests/baselines/reference/genericRestParameters3.types b/tests/baselines/reference/genericRestParameters3.types index be5b2c2091d05..d582932ba8124 100644 --- a/tests/baselines/reference/genericRestParameters3.types +++ b/tests/baselines/reference/genericRestParameters3.types @@ -230,10 +230,10 @@ foo2(...x2); // Repros from #47754 type RestParams = [y: string] | [y: number]; ->RestParams : RestParams +>RestParams : [y: string] | [y: number] type Signature = (x: string, ...rest: RestParams) => void; ->Signature : Signature +>Signature : (x: string, ...rest: RestParams) => void >x : string >rest : RestParams diff --git a/tests/baselines/reference/genericRestTypes.types b/tests/baselines/reference/genericRestTypes.types index 63eb00c63ba19..9341cfeefd5cc 100644 --- a/tests/baselines/reference/genericRestTypes.types +++ b/tests/baselines/reference/genericRestTypes.types @@ -10,12 +10,12 @@ type Tail = ((...args: T) => any) extends ((head: any, ...tail: >tail : U type MyFunctionType = (foo: number, bar: string) => boolean; ->MyFunctionType : MyFunctionType +>MyFunctionType : (foo: number, bar: string) => boolean >foo : number >bar : string type Explicit = (...args: Tail>) => ReturnType; // (bar: string) => boolean ->Explicit : Explicit +>Explicit : (bar: string) => ReturnType >args : [bar: string] type Bind1 any> = (...args: Tail>) => ReturnType; @@ -25,7 +25,7 @@ type Bind1 any> = (...args: Tailargs : Tail> type Generic = Bind1; // (bar: string) => boolean ->Generic : Generic +>Generic : (bar: string) => boolean function assignmentWithComplexRest() { >assignmentWithComplexRest : () => void diff --git a/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt b/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt index 6d7b87ebd3351..b00dfc3c32857 100644 --- a/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt +++ b/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt @@ -1,10 +1,8 @@ tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(2,5): error TS2339: Property 'toString' does not exist on type 'T'. -tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(15,6): error TS2345: Argument of type 'T' is not assignable to parameter of type '{}'. -tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(16,6): error TS2345: Argument of type 'T' is not assignable to parameter of type 'Record'. tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(17,5): error TS2339: Property 'toString' does not exist on type 'T'. -==== tests/cases/compiler/genericUnboundedTypeParamAssignability.ts (4 errors) ==== +==== tests/cases/compiler/genericUnboundedTypeParamAssignability.ts (2 errors) ==== function f1(o: T) { o.toString(); // error ~~~~~~~~ @@ -22,13 +20,7 @@ tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(17,5): error TS23 function user(t: T) { f1(t); f2(t); // error in strict, unbounded T doesn't satisfy the constraint - ~ -!!! error TS2345: Argument of type 'T' is not assignable to parameter of type '{}'. -!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter probably needs an `extends object` constraint. f3(t); // error in strict, unbounded T doesn't satisfy the constraint - ~ -!!! error TS2345: Argument of type 'T' is not assignable to parameter of type 'Record'. -!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter probably needs an `extends object` constraint. t.toString(); // error, for the same reason as f1() ~~~~~~~~ !!! error TS2339: Property 'toString' does not exist on type 'T'. diff --git a/tests/baselines/reference/getParameterNameAtPosition.types b/tests/baselines/reference/getParameterNameAtPosition.types index 1e0c92129010b..8eb527b41ec71 100644 --- a/tests/baselines/reference/getParameterNameAtPosition.types +++ b/tests/baselines/reference/getParameterNameAtPosition.types @@ -6,7 +6,7 @@ interface Mock extends Function { >args : Y } type Tester = (opts: any, done: (...args: any[]) => any) => any; ->Tester : Tester +>Tester : (opts: any, done: (...args: any[]) => any) => any >opts : any >done : (...args: any[]) => any >args : any[] diff --git a/tests/baselines/reference/globalThisAmbientModules.errors.txt b/tests/baselines/reference/globalThisAmbientModules.errors.txt new file mode 100644 index 0000000000000..b29d977475fe2 --- /dev/null +++ b/tests/baselines/reference/globalThisAmbientModules.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/es2019/globalThisAmbientModules.ts(8,39): error TS2339: Property '"ambientModule"' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisAmbientModules.ts(11,33): error TS2339: Property '"ambientModule"' does not exist on type 'typeof globalThis'. + + +==== tests/cases/conformance/es2019/globalThisAmbientModules.ts (2 errors) ==== + declare module "ambientModule" { + export type typ = 1 + export var val: typ + } + namespace valueModule { export var val = 1 } + namespace namespaceModule { export type typ = 1 } + // should error + type GlobalBad1 = (typeof globalThis)["\"ambientModule\""] + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2339: Property '"ambientModule"' does not exist on type 'typeof globalThis'. + type GlobalOk1 = (typeof globalThis)["valueModule"] + type GlobalOk2 = globalThis.namespaceModule.typ + const bad1: (typeof globalThis)["\"ambientModule\""] = 'ambientModule' + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2339: Property '"ambientModule"' does not exist on type 'typeof globalThis'. + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisAmbientModules.js b/tests/baselines/reference/globalThisAmbientModules.js new file mode 100644 index 0000000000000..ec032568e9b22 --- /dev/null +++ b/tests/baselines/reference/globalThisAmbientModules.js @@ -0,0 +1,20 @@ +//// [globalThisAmbientModules.ts] +declare module "ambientModule" { + export type typ = 1 + export var val: typ +} +namespace valueModule { export var val = 1 } +namespace namespaceModule { export type typ = 1 } +// should error +type GlobalBad1 = (typeof globalThis)["\"ambientModule\""] +type GlobalOk1 = (typeof globalThis)["valueModule"] +type GlobalOk2 = globalThis.namespaceModule.typ +const bad1: (typeof globalThis)["\"ambientModule\""] = 'ambientModule' + + +//// [globalThisAmbientModules.js] +var valueModule; +(function (valueModule) { + valueModule.val = 1; +})(valueModule || (valueModule = {})); +var bad1 = 'ambientModule'; diff --git a/tests/baselines/reference/globalThisAmbientModules.symbols b/tests/baselines/reference/globalThisAmbientModules.symbols new file mode 100644 index 0000000000000..f27f2461baa59 --- /dev/null +++ b/tests/baselines/reference/globalThisAmbientModules.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/es2019/globalThisAmbientModules.ts === +declare module "ambientModule" { +>"ambientModule" : Symbol("ambientModule", Decl(globalThisAmbientModules.ts, 0, 0)) + + export type typ = 1 +>typ : Symbol(typ, Decl(globalThisAmbientModules.ts, 0, 32)) + + export var val: typ +>val : Symbol(val, Decl(globalThisAmbientModules.ts, 2, 14)) +>typ : Symbol(typ, Decl(globalThisAmbientModules.ts, 0, 32)) +} +namespace valueModule { export var val = 1 } +>valueModule : Symbol(valueModule, Decl(globalThisAmbientModules.ts, 3, 1)) +>val : Symbol(val, Decl(globalThisAmbientModules.ts, 4, 34)) + +namespace namespaceModule { export type typ = 1 } +>namespaceModule : Symbol(namespaceModule, Decl(globalThisAmbientModules.ts, 4, 44)) +>typ : Symbol(typ, Decl(globalThisAmbientModules.ts, 5, 27)) + +// should error +type GlobalBad1 = (typeof globalThis)["\"ambientModule\""] +>GlobalBad1 : Symbol(GlobalBad1, Decl(globalThisAmbientModules.ts, 5, 49)) +>globalThis : Symbol(globalThis) + +type GlobalOk1 = (typeof globalThis)["valueModule"] +>GlobalOk1 : Symbol(GlobalOk1, Decl(globalThisAmbientModules.ts, 7, 58)) +>globalThis : Symbol(globalThis) + +type GlobalOk2 = globalThis.namespaceModule.typ +>GlobalOk2 : Symbol(GlobalOk2, Decl(globalThisAmbientModules.ts, 8, 51)) +>globalThis : Symbol(globalThis) +>namespaceModule : Symbol(namespaceModule, Decl(globalThisAmbientModules.ts, 4, 44)) +>typ : Symbol(namespaceModule.typ, Decl(globalThisAmbientModules.ts, 5, 27)) + +const bad1: (typeof globalThis)["\"ambientModule\""] = 'ambientModule' +>bad1 : Symbol(bad1, Decl(globalThisAmbientModules.ts, 10, 5)) +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisAmbientModules.types b/tests/baselines/reference/globalThisAmbientModules.types new file mode 100644 index 0000000000000..9357ee67ead24 --- /dev/null +++ b/tests/baselines/reference/globalThisAmbientModules.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/es2019/globalThisAmbientModules.ts === +declare module "ambientModule" { +>"ambientModule" : typeof import("ambientModule") + + export type typ = 1 +>typ : 1 + + export var val: typ +>val : 1 +} +namespace valueModule { export var val = 1 } +>valueModule : typeof valueModule +>val : number +>1 : 1 + +namespace namespaceModule { export type typ = 1 } +>typ : 1 + +// should error +type GlobalBad1 = (typeof globalThis)["\"ambientModule\""] +>GlobalBad1 : any +>globalThis : typeof globalThis + +type GlobalOk1 = (typeof globalThis)["valueModule"] +>GlobalOk1 : typeof valueModule +>globalThis : typeof globalThis + +type GlobalOk2 = globalThis.namespaceModule.typ +>GlobalOk2 : 1 +>globalThis : any +>namespaceModule : any + +const bad1: (typeof globalThis)["\"ambientModule\""] = 'ambientModule' +>bad1 : any +>globalThis : typeof globalThis +>'ambientModule' : "ambientModule" + diff --git a/tests/baselines/reference/hugeDeclarationOutputGetsTruncatedWithError.types b/tests/baselines/reference/hugeDeclarationOutputGetsTruncatedWithError.types index 1db099f87a1a0..28fcd4fd0dffb 100644 --- a/tests/baselines/reference/hugeDeclarationOutputGetsTruncatedWithError.types +++ b/tests/baselines/reference/hugeDeclarationOutputGetsTruncatedWithError.types @@ -1,6 +1,6 @@ === tests/cases/compiler/hugeDeclarationOutputGetsTruncatedWithError.ts === type props = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"; ->props : props +>props : "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" type manyprops = `${props}${props}`; >manyprops : "aa" | "ab" | "ac" | "ad" | "ae" | "af" | "ag" | "ah" | "ai" | "aj" | "ak" | "al" | "am" | "an" | "ao" | "ap" | "aq" | "ar" | "as" | "at" | "au" | "av" | "aw" | "ax" | "ay" | "az" | "ba" | "bb" | "bc" | "bd" | "be" | "bf" | "bg" | "bh" | "bi" | "bj" | "bk" | "bl" | "bm" | "bn" | "bo" | "bp" | "bq" | "br" | "bs" | "bt" | "bu" | "bv" | "bw" | "bx" | "by" | "bz" | "ca" | "cb" | "cc" | "cd" | "ce" | "cf" | "cg" | "ch" | "ci" | "cj" | "ck" | "cl" | "cm" | "cn" | "co" | "cp" | "cq" | "cr" | "cs" | "ct" | "cu" | "cv" | "cw" | "cx" | "cy" | "cz" | "da" | "db" | "dc" | "dd" | "de" | "df" | "dg" | "dh" | "di" | "dj" | "dk" | "dl" | "dm" | "dn" | "do" | "dp" | "dq" | "dr" | "ds" | "dt" | "du" | "dv" | "dw" | "dx" | "dy" | "dz" | "ea" | "eb" | "ec" | "ed" | "ee" | "ef" | "eg" | "eh" | "ei" | "ej" | "ek" | "el" | "em" | "en" | "eo" | "ep" | "eq" | "er" | "es" | "et" | "eu" | "ev" | "ew" | "ex" | "ey" | "ez" | "fa" | "fb" | "fc" | "fd" | "fe" | "ff" | "fg" | "fh" | "fi" | "fj" | "fk" | "fl" | "fm" | "fn" | "fo" | "fp" | "fq" | "fr" | "fs" | "ft" | "fu" | "fv" | "fw" | "fx" | "fy" | "fz" | "ga" | "gb" | "gc" | "gd" | "ge" | "gf" | "gg" | "gh" | "gi" | "gj" | "gk" | "gl" | "gm" | "gn" | "go" | "gp" | "gq" | "gr" | "gs" | "gt" | "gu" | "gv" | "gw" | "gx" | "gy" | "gz" | "ha" | "hb" | "hc" | "hd" | "he" | "hf" | "hg" | "hh" | "hi" | "hj" | "hk" | "hl" | "hm" | "hn" | "ho" | "hp" | "hq" | "hr" | "hs" | "ht" | "hu" | "hv" | "hw" | "hx" | "hy" | "hz" | "ia" | "ib" | "ic" | "id" | "ie" | "if" | "ig" | "ih" | "ii" | "ij" | "ik" | "il" | "im" | "in" | "io" | "ip" | "iq" | "ir" | "is" | "it" | "iu" | "iv" | "iw" | "ix" | "iy" | "iz" | "ja" | "jb" | "jc" | "jd" | "je" | "jf" | "jg" | "jh" | "ji" | "jj" | "jk" | "jl" | "jm" | "jn" | "jo" | "jp" | "jq" | "jr" | "js" | "jt" | "ju" | "jv" | "jw" | "jx" | "jy" | "jz" | "ka" | "kb" | "kc" | "kd" | "ke" | "kf" | "kg" | "kh" | "ki" | "kj" | "kk" | "kl" | "km" | "kn" | "ko" | "kp" | "kq" | "kr" | "ks" | "kt" | "ku" | "kv" | "kw" | "kx" | "ky" | "kz" | "la" | "lb" | "lc" | "ld" | "le" | "lf" | "lg" | "lh" | "li" | "lj" | "lk" | "ll" | "lm" | "ln" | "lo" | "lp" | "lq" | "lr" | "ls" | "lt" | "lu" | "lv" | "lw" | "lx" | "ly" | "lz" | "ma" | "mb" | "mc" | "md" | "me" | "mf" | "mg" | "mh" | "mi" | "mj" | "mk" | "ml" | "mm" | "mn" | "mo" | "mp" | "mq" | "mr" | "ms" | "mt" | "mu" | "mv" | "mw" | "mx" | "my" | "mz" | "na" | "nb" | "nc" | "nd" | "ne" | "nf" | "ng" | "nh" | "ni" | "nj" | "nk" | "nl" | "nm" | "nn" | "no" | "np" | "nq" | "nr" | "ns" | "nt" | "nu" | "nv" | "nw" | "nx" | "ny" | "nz" | "oa" | "ob" | "oc" | "od" | "oe" | "of" | "og" | "oh" | "oi" | "oj" | "ok" | "ol" | "om" | "on" | "oo" | "op" | "oq" | "or" | "os" | "ot" | "ou" | "ov" | "ow" | "ox" | "oy" | "oz" | "pa" | "pb" | "pc" | "pd" | "pe" | "pf" | "pg" | "ph" | "pi" | "pj" | "pk" | "pl" | "pm" | "pn" | "po" | "pp" | "pq" | "pr" | "ps" | "pt" | "pu" | "pv" | "pw" | "px" | "py" | "pz" | "qa" | "qb" | "qc" | "qd" | "qe" | "qf" | "qg" | "qh" | "qi" | "qj" | "qk" | "ql" | "qm" | "qn" | "qo" | "qp" | "qq" | "qr" | "qs" | "qt" | "qu" | "qv" | "qw" | "qx" | "qy" | "qz" | "ra" | "rb" | "rc" | "rd" | "re" | "rf" | "rg" | "rh" | "ri" | "rj" | "rk" | "rl" | "rm" | "rn" | "ro" | "rp" | "rq" | "rr" | "rs" | "rt" | "ru" | "rv" | "rw" | "rx" | "ry" | "rz" | "sa" | "sb" | "sc" | "sd" | "se" | "sf" | "sg" | "sh" | "si" | "sj" | "sk" | "sl" | "sm" | "sn" | "so" | "sp" | "sq" | "sr" | "ss" | "st" | "su" | "sv" | "sw" | "sx" | "sy" | "sz" | "ta" | "tb" | "tc" | "td" | "te" | "tf" | "tg" | "th" | "ti" | "tj" | "tk" | "tl" | "tm" | "tn" | "to" | "tp" | "tq" | "tr" | "ts" | "tt" | "tu" | "tv" | "tw" | "tx" | "ty" | "tz" | "ua" | "ub" | "uc" | "ud" | "ue" | "uf" | "ug" | "uh" | "ui" | "uj" | "uk" | "ul" | "um" | "un" | "uo" | "up" | "uq" | "ur" | "us" | "ut" | "uu" | "uv" | "uw" | "ux" | "uy" | "uz" | "va" | "vb" | "vc" | "vd" | "ve" | "vf" | "vg" | "vh" | "vi" | "vj" | "vk" | "vl" | "vm" | "vn" | "vo" | "vp" | "vq" | "vr" | "vs" | "vt" | "vu" | "vv" | "vw" | "vx" | "vy" | "vz" | "wa" | "wb" | "wc" | "wd" | "we" | "wf" | "wg" | "wh" | "wi" | "wj" | "wk" | "wl" | "wm" | "wn" | "wo" | "wp" | "wq" | "wr" | "ws" | "wt" | "wu" | "wv" | "ww" | "wx" | "wy" | "wz" | "xa" | "xb" | "xc" | "xd" | "xe" | "xf" | "xg" | "xh" | "xi" | "xj" | "xk" | "xl" | "xm" | "xn" | "xo" | "xp" | "xq" | "xr" | "xs" | "xt" | "xu" | "xv" | "xw" | "xx" | "xy" | "xz" | "ya" | "yb" | "yc" | "yd" | "ye" | "yf" | "yg" | "yh" | "yi" | "yj" | "yk" | "yl" | "ym" | "yn" | "yo" | "yp" | "yq" | "yr" | "ys" | "yt" | "yu" | "yv" | "yw" | "yx" | "yy" | "yz" | "za" | "zb" | "zc" | "zd" | "ze" | "zf" | "zg" | "zh" | "zi" | "zj" | "zk" | "zl" | "zm" | "zn" | "zo" | "zp" | "zq" | "zr" | "zs" | "zt" | "zu" | "zv" | "zw" | "zx" | "zy" | "zz" diff --git a/tests/baselines/reference/identicalTypesNoDifferByCheckOrder.types b/tests/baselines/reference/identicalTypesNoDifferByCheckOrder.types index e4c691c6b952f..55122319b547b 100644 --- a/tests/baselines/reference/identicalTypesNoDifferByCheckOrder.types +++ b/tests/baselines/reference/identicalTypesNoDifferByCheckOrder.types @@ -11,7 +11,7 @@ interface SomeProps { } type SomePropsX = Required> & Omit; ->SomePropsX : SomePropsX +>SomePropsX : Required> & Omit interface SomePropsClone { x?: string; @@ -25,7 +25,7 @@ interface SomePropsClone { } type SomePropsCloneX = Required> & Omit; ->SomePropsCloneX : SomePropsCloneX +>SomePropsCloneX : Required> & Omit type Validator = {(): boolean, opt?: T}; >Validator : Validator diff --git a/tests/baselines/reference/implementsIncorrectlyNoAssertion.types b/tests/baselines/reference/implementsIncorrectlyNoAssertion.types index 0c121043e176f..60e193e080be4 100644 --- a/tests/baselines/reference/implementsIncorrectlyNoAssertion.types +++ b/tests/baselines/reference/implementsIncorrectlyNoAssertion.types @@ -12,7 +12,7 @@ declare class Bar { >y : string } type Wrapper = Foo & Bar; ->Wrapper : Wrapper +>Wrapper : Foo & Bar class Baz implements Wrapper { >Baz : Baz diff --git a/tests/baselines/reference/implicitIndexSignatures.types b/tests/baselines/reference/implicitIndexSignatures.types index c302edba32fd2..613d0cec7ac5b 100644 --- a/tests/baselines/reference/implicitIndexSignatures.types +++ b/tests/baselines/reference/implicitIndexSignatures.types @@ -1,6 +1,6 @@ === tests/cases/compiler/implicitIndexSignatures.ts === type StringMap = { [x: string]: string }; ->StringMap : StringMap +>StringMap : { [x: string]: string; } >x : string const empty1 = {}; diff --git a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt index fa365df88cdf2..b7a88e8ce62b5 100644 --- a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt @@ -3,14 +3,14 @@ tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import asserti tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(8,11): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments -tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comma not allowed. @@ -49,29 +49,29 @@ tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comm const a = import('./0') const b = import('./0', { assert: { type: "json" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const c = import('./0', { assert: { type: "json", ttype: "typo" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const d = import('./0', { assert: {} }) ~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const dd = import('./0', {}) ~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. declare function foo(): any; const e = import('./0', foo()) ~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const f = import() ~~~~~~~~ !!! message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments const g = import('./0', {}, {}) ~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const h = import('./0', { assert: { type: "json" }},) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. ~ !!! error TS1009: Trailing comma not allowed. diff --git a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt index fb959409350b0..266938cb7cda5 100644 --- a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt @@ -3,15 +3,15 @@ tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import asserti tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ==== @@ -48,31 +48,31 @@ tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic impor ==== tests/cases/conformance/importAssertion/3.ts (9 errors) ==== const a = import('./0') ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const b = import('./0', { assert: { type: "json" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const c = import('./0', { assert: { type: "json", ttype: "typo" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const d = import('./0', { assert: {} }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const dd = import('./0', {}) ~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. declare function foo(): any; const e = import('./0', foo()) ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const f = import() ~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const g = import('./0', {}, {}) ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const h = import('./0', { assert: { type: "json" }},) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt index 43821679002c4..5fbfb92fa50ea 100644 --- a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== @@ -9,10 +9,10 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports ==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ==== import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. var p1 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. p1.then(zero => { return zero.foo(); }) @@ -20,5 +20,5 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports function foo() { const p2 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt index 063b200b6729a..ee698678c3c4d 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt +++ b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,8): tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(7,17): error TS1325: Argument of dynamic import cannot be spread element. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,19): error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations. -tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. @@ -25,6 +25,6 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): ~~~~~~~~~~~~~~ !!! error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations. ~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. ~~~~~~~~~~~~~~ !!! error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt index 5e37388bc02f4..de342b7804767 100644 --- a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt index 5e37388bc02f4..de342b7804767 100644 --- a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt b/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt index 65b8a2d631ef3..53920e4654019 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1326: Dynamic import cannot have type arguments. -tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: Dynamic import cannot have type arguments. +tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. +tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: Dynamic import c "use strict" var p1 = import>("./0"); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1326: Dynamic import cannot have type arguments. +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. var p2 = import<>("./0"); // error ~~~~~~~~~~~~~~~ -!!! error TS1326: Dynamic import cannot have type arguments. \ No newline at end of file +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. \ No newline at end of file diff --git a/tests/baselines/reference/importClause_namedImports.types b/tests/baselines/reference/importClause_namedImports.types index 64c6c12b3881e..798cdb3928a68 100644 --- a/tests/baselines/reference/importClause_namedImports.types +++ b/tests/baselines/reference/importClause_namedImports.types @@ -3,7 +3,7 @@ export class A {} >A : A export type B = { b: string }; ->B : B +>B : { b: string; } >b : string export const C = ""; diff --git a/tests/baselines/reference/importElisionEnum.js b/tests/baselines/reference/importElisionEnum.js new file mode 100644 index 0000000000000..31c9a5bd8f602 --- /dev/null +++ b/tests/baselines/reference/importElisionEnum.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/importElisionEnum.ts] //// + +//// [enum.ts] +export enum MyEnum { + a = 0, + b, + c, + d +} + +//// [index.ts] +import { MyEnum as MyEnumFromModule } from "./enum"; + +enum MyEnum { + a = MyEnumFromModule.a +} + +//// [enum.js] +"use strict"; +exports.__esModule = true; +exports.MyEnum = void 0; +var MyEnum; +(function (MyEnum) { + MyEnum[MyEnum["a"] = 0] = "a"; + MyEnum[MyEnum["b"] = 1] = "b"; + MyEnum[MyEnum["c"] = 2] = "c"; + MyEnum[MyEnum["d"] = 3] = "d"; +})(MyEnum = exports.MyEnum || (exports.MyEnum = {})); +//// [index.js] +"use strict"; +exports.__esModule = true; +var MyEnum; +(function (MyEnum) { + MyEnum[MyEnum["a"] = 0] = "a"; +})(MyEnum || (MyEnum = {})); diff --git a/tests/baselines/reference/importElisionEnum.symbols b/tests/baselines/reference/importElisionEnum.symbols new file mode 100644 index 0000000000000..5e81a547d67fc --- /dev/null +++ b/tests/baselines/reference/importElisionEnum.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/enum.ts === +export enum MyEnum { +>MyEnum : Symbol(MyEnum, Decl(enum.ts, 0, 0)) + + a = 0, +>a : Symbol(MyEnum.a, Decl(enum.ts, 0, 20)) + + b, +>b : Symbol(MyEnum.b, Decl(enum.ts, 1, 8)) + + c, +>c : Symbol(MyEnum.c, Decl(enum.ts, 2, 4)) + + d +>d : Symbol(MyEnum.d, Decl(enum.ts, 3, 4)) +} + +=== tests/cases/compiler/index.ts === +import { MyEnum as MyEnumFromModule } from "./enum"; +>MyEnum : Symbol(MyEnumFromModule, Decl(enum.ts, 0, 0)) +>MyEnumFromModule : Symbol(MyEnumFromModule, Decl(index.ts, 0, 8)) + +enum MyEnum { +>MyEnum : Symbol(MyEnum, Decl(index.ts, 0, 52)) + + a = MyEnumFromModule.a +>a : Symbol(MyEnum.a, Decl(index.ts, 2, 13)) +>MyEnumFromModule.a : Symbol(MyEnumFromModule.a, Decl(enum.ts, 0, 20)) +>MyEnumFromModule : Symbol(MyEnumFromModule, Decl(index.ts, 0, 8)) +>a : Symbol(MyEnumFromModule.a, Decl(enum.ts, 0, 20)) +} diff --git a/tests/baselines/reference/importElisionEnum.types b/tests/baselines/reference/importElisionEnum.types new file mode 100644 index 0000000000000..17e8b874bf08d --- /dev/null +++ b/tests/baselines/reference/importElisionEnum.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/enum.ts === +export enum MyEnum { +>MyEnum : MyEnum + + a = 0, +>a : MyEnum.a +>0 : 0 + + b, +>b : MyEnum.b + + c, +>c : MyEnum.c + + d +>d : MyEnum.d +} + +=== tests/cases/compiler/index.ts === +import { MyEnum as MyEnumFromModule } from "./enum"; +>MyEnum : typeof MyEnumFromModule +>MyEnumFromModule : typeof MyEnumFromModule + +enum MyEnum { +>MyEnum : MyEnum + + a = MyEnumFromModule.a +>a : MyEnum +>MyEnumFromModule.a : MyEnumFromModule.a +>MyEnumFromModule : typeof MyEnumFromModule +>a : MyEnumFromModule.a +} diff --git a/tests/baselines/reference/importEqualsError45874.types b/tests/baselines/reference/importEqualsError45874.types index 9e3c9c2945eae..7a3d70e746585 100644 --- a/tests/baselines/reference/importEqualsError45874.types +++ b/tests/baselines/reference/importEqualsError45874.types @@ -3,7 +3,7 @@ namespace globals { >globals : typeof globals export type Foo = {}; ->Foo : Foo +>Foo : {} export const Bar = {}; >Bar : {} diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt index 9c82043ec74d1..2f65f3fc12c15 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt @@ -1,25 +1,25 @@ error TS2468: Cannot find global value 'Promise'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. @@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. export let y = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? export let z = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ==== let globalA = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. let globalB = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? let globalC = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ==== export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. import.meta = foo; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS const { a, b, c } = import.meta.wellKnownProperty; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. \ No newline at end of file +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=es5).symbols b/tests/baselines/reference/importMeta(module=commonjs,target=es5).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=es5).symbols +++ b/tests/baselines/reference/importMeta(module=commonjs,target=es5).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt index 9c82043ec74d1..2f65f3fc12c15 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt @@ -1,25 +1,25 @@ error TS2468: Cannot find global value 'Promise'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. @@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. export let y = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? export let z = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ==== let globalA = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. let globalB = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? let globalC = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ==== export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. import.meta = foo; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS const { a, b, c } = import.meta.wellKnownProperty; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. \ No newline at end of file +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).symbols b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).symbols +++ b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=es2020,target=es5).symbols b/tests/baselines/reference/importMeta(module=es2020,target=es5).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=es2020,target=es5).symbols +++ b/tests/baselines/reference/importMeta(module=es2020,target=es5).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=es2020,target=esnext).symbols b/tests/baselines/reference/importMeta(module=es2020,target=esnext).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=es2020,target=esnext).symbols +++ b/tests/baselines/reference/importMeta(module=es2020,target=esnext).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=esnext,target=es5).symbols b/tests/baselines/reference/importMeta(module=esnext,target=es5).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=esnext,target=es5).symbols +++ b/tests/baselines/reference/importMeta(module=esnext,target=es5).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=esnext,target=esnext).symbols b/tests/baselines/reference/importMeta(module=esnext,target=esnext).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=esnext,target=esnext).symbols +++ b/tests/baselines/reference/importMeta(module=esnext,target=esnext).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=system,target=es5).symbols b/tests/baselines/reference/importMeta(module=system,target=es5).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=system,target=es5).symbols +++ b/tests/baselines/reference/importMeta(module=system,target=es5).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMeta(module=system,target=esnext).symbols b/tests/baselines/reference/importMeta(module=system,target=esnext).symbols index d012bf0903c31..334c5c3c32746 100644 --- a/tests/baselines/reference/importMeta(module=system,target=esnext).symbols +++ b/tests/baselines/reference/importMeta(module=system,target=esnext).symbols @@ -8,6 +8,7 @@ >URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) >toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --)) @@ -20,6 +21,7 @@ const size = import.meta.scriptElement.dataset.size || 300; >size : Symbol(size, Decl(example.ts, 5, 7)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) const image = new Image(); >image : Symbol(image, Decl(example.ts, 7, 7)) @@ -57,6 +59,7 @@ export let x = import.meta; >x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) export let y = import.metal; >y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10)) @@ -68,6 +71,7 @@ export let z = import.import.import.malkovich; let globalA = import.meta; >globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) let globalB = import.metal; >globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3)) @@ -80,11 +84,15 @@ export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) >ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) import.meta = foo; >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12)) // @Filename augmentations.ts @@ -108,5 +116,6 @@ const { a, b, c } = import.meta.wellKnownProperty; >c : Symbol(c, Decl(assignmentTargets.ts, 10, 13)) >import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16)) +>meta : Symbol(ImportMetaExpression.meta) >wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24)) diff --git a/tests/baselines/reference/importMetaNarrowing(module=es2020).symbols b/tests/baselines/reference/importMetaNarrowing(module=es2020).symbols index f2c77663a5085..4d932447a7cdf 100644 --- a/tests/baselines/reference/importMetaNarrowing(module=es2020).symbols +++ b/tests/baselines/reference/importMetaNarrowing(module=es2020).symbols @@ -7,11 +7,13 @@ declare global { interface ImportMeta {foo?: () => void} }; if (import.meta.foo) { >import.meta.foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(importMetaNarrowing.ts, 0, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) import.meta.foo(); >import.meta.foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(importMetaNarrowing.ts, 0, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) } diff --git a/tests/baselines/reference/importMetaNarrowing(module=esnext).symbols b/tests/baselines/reference/importMetaNarrowing(module=esnext).symbols index f2c77663a5085..4d932447a7cdf 100644 --- a/tests/baselines/reference/importMetaNarrowing(module=esnext).symbols +++ b/tests/baselines/reference/importMetaNarrowing(module=esnext).symbols @@ -7,11 +7,13 @@ declare global { interface ImportMeta {foo?: () => void} }; if (import.meta.foo) { >import.meta.foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(importMetaNarrowing.ts, 0, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) import.meta.foo(); >import.meta.foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(importMetaNarrowing.ts, 0, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) } diff --git a/tests/baselines/reference/importMetaNarrowing(module=system).symbols b/tests/baselines/reference/importMetaNarrowing(module=system).symbols index f2c77663a5085..4d932447a7cdf 100644 --- a/tests/baselines/reference/importMetaNarrowing(module=system).symbols +++ b/tests/baselines/reference/importMetaNarrowing(module=system).symbols @@ -7,11 +7,13 @@ declare global { interface ImportMeta {foo?: () => void} }; if (import.meta.foo) { >import.meta.foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(importMetaNarrowing.ts, 0, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) import.meta.foo(); >import.meta.foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) >import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(importMetaNarrowing.ts, 0, 16)) +>meta : Symbol(ImportMetaExpression.meta) >foo : Symbol(ImportMeta.foo, Decl(importMetaNarrowing.ts, 0, 39)) } diff --git a/tests/baselines/reference/importPropertyFromMappedType.types b/tests/baselines/reference/importPropertyFromMappedType.types index efc06ad38e4a0..696cb83599dc5 100644 --- a/tests/baselines/reference/importPropertyFromMappedType.types +++ b/tests/baselines/reference/importPropertyFromMappedType.types @@ -10,7 +10,7 @@ declare const createHttpError: createHttpError.NamedConstructors; declare namespace createHttpError { type NamedConstructors = { [P in 'NotFound']: unknown;} ->NamedConstructors : NamedConstructors +>NamedConstructors : { NotFound: unknown; } } === tests/cases/compiler/main.ts === diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types index 6501bab43e581..7e71235bb2fb1 100644 --- a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types @@ -3,7 +3,7 @@ export as namespace UMD; >UMD : typeof import("tests/cases/compiler/node_modules/umd") export type Thing = { ->Thing : Thing +>Thing : { a: number; } a: number; >a : number diff --git a/tests/baselines/reference/importTypeGenericArrowTypeParenthesized.types b/tests/baselines/reference/importTypeGenericArrowTypeParenthesized.types index 1da9f5906973f..fe9cf70f63465 100644 --- a/tests/baselines/reference/importTypeGenericArrowTypeParenthesized.types +++ b/tests/baselines/reference/importTypeGenericArrowTypeParenthesized.types @@ -41,7 +41,7 @@ export const works1 = fn((x: number) => x); >x : number type MakeItWork = (x: T) => T; ->MakeItWork : MakeItWork +>MakeItWork : (x: T) => T >x : T export const works2 = fn(x => x); diff --git a/tests/baselines/reference/importWithTypeArguments.errors.txt b/tests/baselines/reference/importWithTypeArguments.errors.txt new file mode 100644 index 0000000000000..2981a63bec737 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/import/importWithTypeArguments.ts(1,1): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. +tests/cases/conformance/types/import/importWithTypeArguments.ts(2,11): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. + + +==== tests/cases/conformance/types/import/importWithTypeArguments.ts (2 errors) ==== + import + ~~~~~~~~~ +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. + const a = import + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. + \ No newline at end of file diff --git a/tests/baselines/reference/importWithTypeArguments.js b/tests/baselines/reference/importWithTypeArguments.js new file mode 100644 index 0000000000000..9a54a823050cb --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.js @@ -0,0 +1,8 @@ +//// [importWithTypeArguments.ts] +import +const a = import + + +//// [importWithTypeArguments.js] +import; +var a = (import); diff --git a/tests/baselines/reference/importWithTypeArguments.symbols b/tests/baselines/reference/importWithTypeArguments.symbols new file mode 100644 index 0000000000000..5f769bb1978e7 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/types/import/importWithTypeArguments.ts === +import +>T : Symbol(T) + +const a = import +>a : Symbol(a, Decl(importWithTypeArguments.ts, 1, 5)) + diff --git a/tests/baselines/reference/importWithTypeArguments.types b/tests/baselines/reference/importWithTypeArguments.types new file mode 100644 index 0000000000000..442b3cc9ed993 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/types/import/importWithTypeArguments.ts === +import +const a = import +>a : any + diff --git a/tests/baselines/reference/importsNotUsedAsValues_error.types b/tests/baselines/reference/importsNotUsedAsValues_error.types index cbe4fc62703c9..99acfb8041ed2 100644 --- a/tests/baselines/reference/importsNotUsedAsValues_error.types +++ b/tests/baselines/reference/importsNotUsedAsValues_error.types @@ -4,7 +4,7 @@ export class A {} >A : A export type B = {}; ->B : B +>B : {} export const enum C { One, Two } >C : C diff --git a/tests/baselines/reference/inKeywordTypeguard.types b/tests/baselines/reference/inKeywordTypeguard.types index e0956d838e2ec..cb0c545088822 100644 --- a/tests/baselines/reference/inKeywordTypeguard.types +++ b/tests/baselines/reference/inKeywordTypeguard.types @@ -383,7 +383,7 @@ function narrowsToNever(x: { l: number } | { r: number }) { } type AOrB = { aProp: number } | { bProp: number }; ->AOrB : AOrB +>AOrB : { aProp: number; } | { bProp: number; } >aProp : number >bProp : number diff --git a/tests/baselines/reference/indexSignatureAndMappedType.types b/tests/baselines/reference/indexSignatureAndMappedType.types index 9f3b3e3fe6cc5..c6b129bc4f7a1 100644 --- a/tests/baselines/reference/indexSignatureAndMappedType.types +++ b/tests/baselines/reference/indexSignatureAndMappedType.types @@ -56,7 +56,7 @@ function f3(x: { [key: string]: T }, y: Record) { // Repro from #14548 type Dictionary = { ->Dictionary : Dictionary +>Dictionary : { [key: string]: string; } [key: string]: string; >key : string diff --git a/tests/baselines/reference/indexSignatureWithTrailingComma.types b/tests/baselines/reference/indexSignatureWithTrailingComma.types index 095e97c6e2d56..9f37e452ab7d6 100644 --- a/tests/baselines/reference/indexSignatureWithTrailingComma.types +++ b/tests/baselines/reference/indexSignatureWithTrailingComma.types @@ -1,6 +1,6 @@ === tests/cases/compiler/indexSignatureWithTrailingComma.ts === type A = { ->A : A +>A : { [key: string]: string; } [key: string,]: string; >key : string diff --git a/tests/baselines/reference/indexSignatures1.types b/tests/baselines/reference/indexSignatures1.types index 720f4357c1904..a114c1cf33dda 100644 --- a/tests/baselines/reference/indexSignatures1.types +++ b/tests/baselines/reference/indexSignatures1.types @@ -179,7 +179,7 @@ dom = { date123: 'hello' }; // Error // Contextual typing by index signature with template literal pattern type Funcs = { ->Funcs : Funcs +>Funcs : { [key: `s${string}`]: (x: string) => void; [key: `n${string}`]: (x: number) => void; } [key: `s${string}`]: (x: string) => void, >key : `s${string}` @@ -214,7 +214,7 @@ const funcs: Funcs = { // Duplicate index signature checking type Duplicates = { ->Duplicates : Duplicates +>Duplicates : { [key: string]: any; [key: number]: any; [key: symbol]: any; [key: `foo${string}`]: any; } [key: string | number]: any; // Error >key : string | number @@ -232,7 +232,7 @@ type Duplicates = { // Conflicting index signature checking type Conflicting = { ->Conflicting : Conflicting +>Conflicting : { [key: `a${string}`]: "a"; [key: `${string}a`]: "b"; [key: `a${string}a`]: "c"; } [key: `a${string}`]: 'a'; >key : `a${string}` @@ -265,18 +265,18 @@ type Invalid = { // Intersections in index signatures type Tag1 = { __tag1__: void }; ->Tag1 : Tag1 +>Tag1 : { __tag1__: void; } >__tag1__ : void type Tag2 = { __tag2__: void }; ->Tag2 : Tag2 +>Tag2 : { __tag2__: void; } >__tag2__ : void type TaggedString1 = string & Tag1; ->TaggedString1 : TaggedString1 +>TaggedString1 : string & Tag1 type TaggedString2 = string & Tag2; ->TaggedString2 : TaggedString2 +>TaggedString2 : string & Tag2 declare let s0: string; >s0 : string @@ -958,7 +958,7 @@ const AmIPseudo: Pseudo = '&'; // Error >'&' : "&" type PseudoDeclaration = { [key in Pseudo]: string }; ->PseudoDeclaration : PseudoDeclaration +>PseudoDeclaration : { [x: `&:${string}`]: string; } const test: PseudoDeclaration = { 'someKey' : 'someValue' }; // Error >test : PseudoDeclaration @@ -978,7 +978,7 @@ const path2: FieldPattern = 'two'; // Error >'two' : "two" type PathsObject = { [P in FieldPattern]: object; }; ->PathsObject : PathsObject +>PathsObject : { [x: `/${string}`]: object; } const pathObject: PathsObject = 123; // Error >pathObject : PathsObject @@ -992,7 +992,7 @@ const id: IdType = '0000-0000-0000-0001'; >'0000-0000-0000-0001' : "0000-0000-0000-0001" type A = Record; ->A : A +>A : { [x: `${number}-${number}-${number}-${number}`]: string; } const a: A = { [id]: 'test' } >a : A @@ -1054,15 +1054,15 @@ const obj3: { [key: number]: string } = { [sym]: 'hello '}; // Error // Repro from #45772 type Id = string & { __tag: 'id '}; ->Id : Id +>Id : string & { __tag: 'id '; } >__tag : "id " type Rec1 = { [key: Id]: number }; ->Rec1 : Rec1 +>Rec1 : { [key: Id]: number; } >key : Id type Rec2 = Record; ->Rec2 : Rec2 +>Rec2 : { [x: string & { __tag: "id "; }]: number; } type K1 = keyof Rec1; // Id >K1 : Id diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types index 8c4739cf4879b..b7a4e79d89a94 100644 --- a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types @@ -1,6 +1,6 @@ === tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts === type AnyFunction = (...args: any[]) => any; ->AnyFunction : AnyFunction +>AnyFunction : (...args: any[]) => any >args : any[] type Params = Parameters>; diff --git a/tests/baselines/reference/indexedAccessNormalization.types b/tests/baselines/reference/indexedAccessNormalization.types index 53d57f4319ae7..418be2989a710 100644 --- a/tests/baselines/reference/indexedAccessNormalization.types +++ b/tests/baselines/reference/indexedAccessNormalization.types @@ -11,7 +11,7 @@ type MyMap = { } declare function g(value?: T): void; ->g : (value?: T | undefined) => void +>g : (value?: T) => void >value : T | undefined function f1(mymap: MyMap, k: keyof M) { diff --git a/tests/baselines/reference/indexedAccessRetainsIndexSignature.types b/tests/baselines/reference/indexedAccessRetainsIndexSignature.types index 830ee6629fa8e..fa1dafca6dc0a 100644 --- a/tests/baselines/reference/indexedAccessRetainsIndexSignature.types +++ b/tests/baselines/reference/indexedAccessRetainsIndexSignature.types @@ -17,7 +17,7 @@ type Omit2 = {[P in Diff]: T[P]}; >Omit2 : Omit2 type O = Omit<{ a: number, b: string }, 'a'> ->O : O +>O : { b: string; } >a : number >b : string diff --git a/tests/baselines/reference/indexerConstraints2.types b/tests/baselines/reference/indexerConstraints2.types index 9c9222816379e..9a0e92d169932 100644 --- a/tests/baselines/reference/indexerConstraints2.types +++ b/tests/baselines/reference/indexerConstraints2.types @@ -83,7 +83,7 @@ interface N { } type IndexableUnion = "foo" | "bar"; ->IndexableUnion : IndexableUnion +>IndexableUnion : "foo" | "bar" interface O { [u: IndexableUnion]: A; @@ -91,7 +91,7 @@ interface O { } type NonIndexableUnion = boolean | {}; ->NonIndexableUnion : NonIndexableUnion +>NonIndexableUnion : boolean | {} interface P { [u: NonIndexableUnion]: A; @@ -99,7 +99,7 @@ interface P { } type NonIndexableUnion2 = string | number; ->NonIndexableUnion2 : NonIndexableUnion2 +>NonIndexableUnion2 : string | number interface Q { [u: NonIndexableUnion2]: A; @@ -107,7 +107,7 @@ interface Q { } type NonIndexableUnion3 = "foo" | 42; ->NonIndexableUnion3 : NonIndexableUnion3 +>NonIndexableUnion3 : "foo" | 42 interface R { [u: NonIndexableUnion3]: A; diff --git a/tests/baselines/reference/indexingTypesWithNever.types b/tests/baselines/reference/indexingTypesWithNever.types index dc0a535331875..84eefc13fab54 100644 --- a/tests/baselines/reference/indexingTypesWithNever.types +++ b/tests/baselines/reference/indexingTypesWithNever.types @@ -1,6 +1,6 @@ === tests/cases/compiler/indexingTypesWithNever.ts === type TestObj = { ->TestObj : TestObj +>TestObj : { a: string; b: number; } a: string; >a : string @@ -15,7 +15,7 @@ type Result1 = TestObj[never]; >Result1 : never type EmptyObj = {}; ->EmptyObj : EmptyObj +>EmptyObj : {} // Should be never but without an error type Result2 = EmptyObj[keyof EmptyObj]; @@ -127,25 +127,25 @@ type ExpectType = Match extends "Match" : "Did not match"; type P3 = { a: string; b: number; c?: boolean }; ->P3 : P3 +>P3 : { a: string; b: number; c?: boolean | undefined; } >a : string >b : number >c : boolean | undefined type P2 = { a: string; c?: boolean }; ->P2 : P2 +>P2 : { a: string; c?: boolean | undefined; } >a : string >c : boolean | undefined type P1 = { c?: boolean }; ->P1 : P1 +>P1 : { c?: boolean | undefined; } >c : boolean | undefined type P0 = {}; ->P0 : P0 +>P0 : {} type P3Names = RequiredPropNames; // expect 'a' | 'b' ->P3Names : P3Names +>P3Names : "a" | "b" type P2Names = RequiredPropNames; // expect 'a' >P2Names : "a" @@ -169,16 +169,16 @@ declare const p0NameTest: ExpectType; >p0NameTest : "Match" type P3Props = RequiredProps; // expect { a: string; b: number } ->P3Props : P3Props +>P3Props : { a: string; b: number; } type P2Props = RequiredProps; // expect { a: string; } ->P2Props : P2Props +>P2Props : { a: string; } type P1Props = RequiredProps; // expect {} ->P1Props : P1Props +>P1Props : {} type P0Props = RequiredProps; // expect {} ->P0Props : P0Props +>P0Props : {} declare const p3Test: ExpectType<{ a: string; b: number }, P3Props>; >p3Test : "Match" @@ -196,25 +196,25 @@ declare const p0Test: ExpectType<{}, P0Props>; >p0Test : "Match" type O3 = { a?: string; b?: number; c: boolean }; ->O3 : O3 +>O3 : { a?: string | undefined; b?: number | undefined; c: boolean; } >a : string | undefined >b : number | undefined >c : boolean type O2 = { a?: string; c: boolean }; ->O2 : O2 +>O2 : { a?: string | undefined; c: boolean; } >a : string | undefined >c : boolean type O1 = { c: boolean }; ->O1 : O1 +>O1 : { c: boolean; } >c : boolean type O0 = {}; ->O0 : O0 +>O0 : {} type O3Names = OptionalPropNames; // expect 'a' | 'b' ->O3Names : O3Names +>O3Names : "a" | "b" type O2Names = OptionalPropNames; // expect 'a' >O2Names : "a" @@ -238,16 +238,16 @@ declare const o0NameTest: ExpectType; >o0NameTest : "Match" type O3Props = OptionalProps; // expect { a?: string | undefined; b?: number | undefined } ->O3Props : O3Props +>O3Props : { a?: string | undefined; b?: number | undefined; } type O2Props = OptionalProps; // expect { a?: string | undefined; } ->O2Props : O2Props +>O2Props : { a?: string | undefined; } type O1Props = OptionalProps; // expect {} ->O1Props : O1Props +>O1Props : {} type O0Props = OptionalProps; // expect {} ->O0Props : O0Props +>O0Props : {} declare const o3Test: ExpectType<{ a?: string; b?: number }, O3Props>; >o3Test : "Match" diff --git a/tests/baselines/reference/indirectTypeParameterReferences.types b/tests/baselines/reference/indirectTypeParameterReferences.types index f874fca104851..d8721c22b1aa0 100644 --- a/tests/baselines/reference/indirectTypeParameterReferences.types +++ b/tests/baselines/reference/indirectTypeParameterReferences.types @@ -2,7 +2,7 @@ // Repro from #19043 type B = {b: string} ->B : B +>B : { b: string; } >b : string const flowtypes = (b: B) => { diff --git a/tests/baselines/reference/inferFromBindingPattern.types b/tests/baselines/reference/inferFromBindingPattern.types index 802fd56f7fcc3..ee217fafa8617 100644 --- a/tests/baselines/reference/inferFromBindingPattern.types +++ b/tests/baselines/reference/inferFromBindingPattern.types @@ -60,7 +60,7 @@ interface Person { } declare function selectJohn(props?: SelectProps): SelectResult; ->selectJohn : (props?: SelectProps | undefined) => SelectResult +>selectJohn : (props?: SelectProps) => SelectResult >props : SelectProps | undefined const [person] = selectJohn(); @@ -91,7 +91,7 @@ declare function makeTuple(arg: T1): [T1]; >arg : T1 declare function stringy(arg?: T): T; ->stringy : (arg?: T | undefined) => T +>stringy : (arg?: T) => T >arg : T | undefined const isStringTuple = makeTuple(stringy()); // [string] diff --git a/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types b/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types index 6eb2bbf32e681..dc1d4b32e9b45 100644 --- a/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types +++ b/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types @@ -172,7 +172,7 @@ export namespace DiagnosticSeverity { } export type DiagnosticSeverity = 1 | 2 | 3 | 4; ->DiagnosticSeverity : DiagnosticSeverity +>DiagnosticSeverity : 1 | 2 | 3 | 4 export interface Diagnostic { severity?: DiagnosticSeverity; @@ -294,7 +294,7 @@ declare function box(value: T): Box; >value : T type WinCondition = ->WinCondition : WinCondition +>WinCondition : { type: 'win'; player: string; } | { type: 'draw'; } | { type: 'win', player: string } >type : "win" @@ -312,7 +312,7 @@ let zz: Box = box({ type: 'draw' }); >'draw' : "draw" type WinType = 'win' | 'draw'; ->WinType : WinType +>WinType : "win" | "draw" let yy: Box = box('draw'); >yy : Box @@ -391,7 +391,7 @@ const a3: I[] = ['a', 'b'].map(name => { // Repro from https://www.memsql.com/blog/porting-30k-lines-of-code-from-flow-to-typescript/ type Player = { ->Player : Player +>Player : { name: string; age: number; position: "STRIKER" | "GOALKEEPER"; } name: string; >name : string @@ -405,7 +405,7 @@ type Player = { }; type F = () => Promise>; ->F : F +>F : () => Promise> const f1: F = () => { >f1 : F @@ -477,7 +477,7 @@ enum State { A, B } >B : State.B type Foo = { state: State } ->Foo : Foo +>Foo : { state: State; } >state : State declare function bar(f: () => T[]): T[]; diff --git a/tests/baselines/reference/inferTInParentheses.types b/tests/baselines/reference/inferTInParentheses.types index c95ebab700aef..1207c2f80f345 100644 --- a/tests/baselines/reference/inferTInParentheses.types +++ b/tests/baselines/reference/inferTInParentheses.types @@ -1,6 +1,6 @@ === tests/cases/compiler/inferTInParentheses.ts === type F1 = (num: [number]) => void; ->F1 : F1 +>F1 : (num: [number]) => void >num : [number] type IsNumber = T; diff --git a/tests/baselines/reference/inferTypes1.types b/tests/baselines/reference/inferTypes1.types index c7a609b3eaed2..964ae6c5c6bcd 100644 --- a/tests/baselines/reference/inferTypes1.types +++ b/tests/baselines/reference/inferTypes1.types @@ -335,7 +335,7 @@ type Jsonified = : "what is this"; type Example = { ->Example : Example +>Example : { str: "literalstring"; fn: () => void; date: Date; customClass: MyClass; obj: { prop: "property"; clz: MyClass; nested: { attr: Date; };}; } str: "literalstring", >str : "literalstring" diff --git a/tests/baselines/reference/inferenceErasedSignatures.types b/tests/baselines/reference/inferenceErasedSignatures.types index 84f64ffda5682..382cc08394ff8 100644 --- a/tests/baselines/reference/inferenceErasedSignatures.types +++ b/tests/baselines/reference/inferenceErasedSignatures.types @@ -15,7 +15,7 @@ abstract class SomeAbstractClass extends SomeBaseClass { >SomeBaseClass : SomeBaseClass foo!: (r?: R) => void; ->foo : (r?: R | undefined) => void +>foo : (r?: R) => void >r : R | undefined bar!: (r?: any) => void; @@ -72,7 +72,7 @@ interface BaseType { >c : T1 useT2(r?: T2): void; ->useT2 : (r?: T2 | undefined) => void +>useT2 : (r?: T2) => void >r : T2 | undefined unrelatedButSomehowRelevant(r?: any): void; @@ -99,7 +99,7 @@ interface StructuralVersion { >c : number useT2(r?: boolean): void; ->useT2 : (r?: boolean | undefined) => void +>useT2 : (r?: boolean) => void >r : boolean | undefined unrelatedButSomehowRelevant(r?: any): void; diff --git a/tests/baselines/reference/inferenceUnionOfObjectsMappedContextualType.types b/tests/baselines/reference/inferenceUnionOfObjectsMappedContextualType.types index 7a0dc327a499f..f017099d6126c 100644 --- a/tests/baselines/reference/inferenceUnionOfObjectsMappedContextualType.types +++ b/tests/baselines/reference/inferenceUnionOfObjectsMappedContextualType.types @@ -1,6 +1,6 @@ === tests/cases/compiler/inferenceUnionOfObjectsMappedContextualType.ts === type Entity = { ->Entity : Entity +>Entity : { someDate: Date | null; } & ({ id: string; } | { id: number; }) someDate: Date | null; >someDate : Date | null diff --git a/tests/baselines/reference/inferrenceInfiniteLoopWithSubtyping.types b/tests/baselines/reference/inferrenceInfiniteLoopWithSubtyping.types index e10562f57bcba..5d1ca14f1c257 100644 --- a/tests/baselines/reference/inferrenceInfiniteLoopWithSubtyping.types +++ b/tests/baselines/reference/inferrenceInfiniteLoopWithSubtyping.types @@ -7,7 +7,7 @@ export type Thunk = (() => T) | T; >Thunk : Thunk export type ComposeOutputTypeDefinition = Readonly | EnumTypeComposer>; ->ComposeOutputTypeDefinition : ComposeOutputTypeDefinition +>ComposeOutputTypeDefinition : Readonly> | Readonly export class EnumTypeComposer { >EnumTypeComposer : EnumTypeComposer diff --git a/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types b/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types index 5035da7bcef17..2656522f57e08 100644 --- a/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types +++ b/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types @@ -1,6 +1,6 @@ === tests/cases/compiler/index.d.ts === export declare function foo({a}?: { ->foo : ({ a }?: { a?: string | undefined; } | undefined) => void +>foo : ({ a }?: { a?: string;}) => void >a : string | undefined a?: string; diff --git a/tests/baselines/reference/instantiateContextualTypes.types b/tests/baselines/reference/instantiateContextualTypes.types index ff6154c78589c..72ea90d59533e 100644 --- a/tests/baselines/reference/instantiateContextualTypes.types +++ b/tests/baselines/reference/instantiateContextualTypes.types @@ -169,7 +169,7 @@ createReducer( // #25814 type R = { ->R : R +>R : { a: (x: number) => void; b: (x: string) => void; } a: (x: number) => void; >a : (x: number) => void @@ -182,7 +182,7 @@ type R = { }; type O = { ->O : O +>O : { on

(x: P, callback: R[P]): void; } on

(x: P, callback: R[P]): void; >on :

(x: P, callback: R[P]) => void @@ -329,7 +329,7 @@ passContentsToFunc(outerBoxOfString, box => box.value); // Repro from #32349 type DooDad = 'SOMETHING' | 'ELSE' ; ->DooDad : DooDad +>DooDad : "SOMETHING" | "ELSE" class Interesting { >Interesting : Interesting diff --git a/tests/baselines/reference/instantiationExpressionErrors.errors.txt b/tests/baselines/reference/instantiationExpressionErrors.errors.txt index d0ded2ca91756..5b60983d594dc 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrors.errors.txt @@ -72,4 +72,9 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpr const x3 = f; true; + + // Parsed as instantiation expression + + const x4 = f + if (true) {} \ No newline at end of file diff --git a/tests/baselines/reference/instantiationExpressionErrors.js b/tests/baselines/reference/instantiationExpressionErrors.js index c0c4d9b5b6818..9f6b17f13787a 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.js +++ b/tests/baselines/reference/instantiationExpressionErrors.js @@ -40,6 +40,11 @@ true; const x3 = f; true; + +// Parsed as instantiation expression + +const x4 = f +if (true) {} //// [instantiationExpressionErrors.js] @@ -70,6 +75,9 @@ var x2 = f < true > // Parsed as instantiation expression var x3 = (f); true; +// Parsed as instantiation expression +var x4 = (f); +if (true) { } //// [instantiationExpressionErrors.d.ts] @@ -101,3 +109,7 @@ declare const x3: { (): true; g(): U; }; +declare const x4: { + (): true; + g(): U; +}; diff --git a/tests/baselines/reference/instantiationExpressionErrors.symbols b/tests/baselines/reference/instantiationExpressionErrors.symbols index a9e99be8987a3..dc1e6d5d64b3c 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.symbols +++ b/tests/baselines/reference/instantiationExpressionErrors.symbols @@ -99,3 +99,11 @@ const x3 = f; true; +// Parsed as instantiation expression + +const x4 = f +>x4 : Symbol(x4, Decl(instantiationExpressionErrors.ts, 44, 5)) +>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11)) + +if (true) {} + diff --git a/tests/baselines/reference/instantiationExpressionErrors.types b/tests/baselines/reference/instantiationExpressionErrors.types index 3886d802526a1..334cb69865e01 100644 --- a/tests/baselines/reference/instantiationExpressionErrors.types +++ b/tests/baselines/reference/instantiationExpressionErrors.types @@ -122,3 +122,13 @@ const x3 = f; true; >true : true +// Parsed as instantiation expression + +const x4 = f +>x4 : { (): true; g(): U; } +>f : { (): T; g(): U; } +>true : true + +if (true) {} +>true : true + diff --git a/tests/baselines/reference/instantiationExpressions.types b/tests/baselines/reference/instantiationExpressions.types index 43a71f42d3ea5..bb35bc036a14a 100644 --- a/tests/baselines/reference/instantiationExpressions.types +++ b/tests/baselines/reference/instantiationExpressions.types @@ -409,14 +409,14 @@ type BoxFunc = typeof makeBox; // (value: T) => { value: T } >makeBox : (value: T) => { value: T; } type StringBoxFunc = BoxFunc; // (value: string) => { value: string } ->StringBoxFunc : StringBoxFunc +>StringBoxFunc : (value: string) => { value: string; } type Box = ReturnType>; // { value: T } >Box : { value: T; } >makeBox : (value: T) => { value: T; } type StringBox = Box; // { value: string } ->StringBox : StringBox +>StringBox : { value: string; } type A = InstanceType>; // U[] >A : U[] diff --git a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types index 6883034052e85..8a984980b2ad1 100644 --- a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types @@ -25,6 +25,6 @@ if (typeof x !== "string") { } type StringTree = string | StringTreeArray; ->StringTree : StringTree +>StringTree : string | StringTreeArray interface StringTreeArray extends Array { } diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.types b/tests/baselines/reference/interfaceExtendsObjectIntersection.types index af63896907833..26ef179f45487 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersection.types +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.types @@ -1,27 +1,27 @@ === tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts === type T1 = { a: number }; ->T1 : T1 +>T1 : { a: number; } >a : number type T2 = T1 & { b: number }; ->T2 : T2 +>T2 : T1 & { b: number; } >b : number type T3 = () => void; ->T3 : T3 +>T3 : () => void type T4 = new () => { a: number }; ->T4 : T4 +>T4 : new () => { a: number;} >a : number type T5 = number[]; ->T5 : T5 +>T5 : number[] type T6 = [string, number]; ->T6 : T6 +>T6 : [string, number] type T7 = { [P in 'a' | 'b' | 'c']: string }; ->T7 : T7 +>T7 : { a: string; b: string; c: string; } interface I1 extends T1 { x: string } >x : string diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types index 2fc15b5399411..651ce89bced13 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types @@ -1,20 +1,20 @@ === tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts === type T1 = { a: number }; ->T1 : T1 +>T1 : { a: number; } >a : number type T2 = T1 & { b: number }; ->T2 : T2 +>T2 : T1 & { b: number; } >b : number type T3 = number[]; ->T3 : T3 +>T3 : number[] type T4 = [string, number]; ->T4 : T4 +>T4 : [string, number] type T5 = { [P in 'a' | 'b' | 'c']: string }; ->T5 : T5 +>T5 : { a: string; b: string; c: string; } interface I1 extends T1 { a: string } >a : string @@ -130,7 +130,7 @@ interface I23 extends Identifiable { a: string } >a : string type U = { a: number } | { b: string }; ->U : U +>U : { a: number; } | { b: string; } >a : number >b : string diff --git a/tests/baselines/reference/intersectionAsWeakTypeSource.types b/tests/baselines/reference/intersectionAsWeakTypeSource.types index 2362f7c92c17f..4c4f552e8cf5c 100644 --- a/tests/baselines/reference/intersectionAsWeakTypeSource.types +++ b/tests/baselines/reference/intersectionAsWeakTypeSource.types @@ -9,7 +9,7 @@ interface Z { z?: boolean } >z : boolean type XY = X & Y; ->XY : XY +>XY : X & Y const xy: XY = {x: 'x', y: 10}; >xy : XY diff --git a/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types index 77805ece13b11..73f063a571df3 100644 --- a/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types +++ b/tests/baselines/reference/intersectionMemberOfUnionNarrowsCorrectly.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts === export type U = { kind?: 'A', a: string } | { kind?: 'B' } & { b: string }; ->U : U +>U : { kind?: 'A'; a: string; } | ({ kind?: 'B'; } & { b: string; }) >kind : "A" >a : string >kind : "B" diff --git a/tests/baselines/reference/intersectionOfUnionNarrowing.types b/tests/baselines/reference/intersectionOfUnionNarrowing.types index 27dc8f3dc6c6c..5a9072bfa60bc 100644 --- a/tests/baselines/reference/intersectionOfUnionNarrowing.types +++ b/tests/baselines/reference/intersectionOfUnionNarrowing.types @@ -9,7 +9,7 @@ interface X { >bProp : string } type AorB = { a: object; b: undefined } | { a: undefined; b: object }; ->AorB : AorB +>AorB : { a: object; b: undefined; } | { a: undefined; b: object; } >a : object >b : undefined >a : undefined diff --git a/tests/baselines/reference/intersectionReduction.types b/tests/baselines/reference/intersectionReduction.types index 482e13483b8c5..4ecfe50e4271b 100644 --- a/tests/baselines/reference/intersectionReduction.types +++ b/tests/baselines/reference/intersectionReduction.types @@ -31,7 +31,7 @@ type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never >sym1 : unique symbol type T10 = string & ('a' | 'b'); // 'a' | 'b' ->T10 : T10 +>T10 : "a" | "b" type T11 = (string | number) & ('a' | 10); // 'a' | 10 >T11 : "a" | 10 @@ -61,7 +61,7 @@ type N7 = void & string; >N7 : never type X = { x: string }; ->X : X +>X : { x: string; } >x : string type X1 = X | 'a' & 'b'; @@ -89,17 +89,17 @@ type X7 = X | void & string; >X7 : X type A = { kind: 'a', foo: string }; ->A : A +>A : { kind: 'a'; foo: string; } >kind : "a" >foo : string type B = { kind: 'b', foo: number }; ->B : B +>B : { kind: 'b'; foo: number; } >kind : "b" >foo : number type C = { kind: 'c', foo: number }; ->C : C +>C : { kind: 'c'; foo: number; } >kind : "c" >foo : number @@ -143,7 +143,7 @@ type K1 = keyof (A & B); // string | number | symbol >K1 : string | number | symbol type K2 = keyof A | keyof B; // 'kind' | 'foo' ->K2 : K2 +>K2 : "kind" | "foo" type Merge1 = { [P in keyof (T & U)]: P extends keyof T ? T[P] : U[P & keyof U] } >Merge1 : Merge1 @@ -159,26 +159,26 @@ type M1 = { a: 1, b: 2 } & { a: 2, c: 3 }; // never >c : 3 type M2 = Merge1<{ a: 1, b: 2 }, { a: 2, c: 3 }>; // {} ->M2 : M2 +>M2 : {} >a : 1 >b : 2 >a : 2 >c : 3 type M3 = Merge2<{ a: 1, b: 2 }, { a: 2, c: 3 }>; // { a: 1, b: 2, c: 3 } ->M3 : M3 +>M3 : { a: 1; b: 2; c: 3; } >a : 1 >b : 2 >a : 2 >c : 3 type D = { kind: 'd', foo: unknown }; ->D : D +>D : { kind: 'd'; foo: unknown; } >kind : "d" >foo : unknown type E = { kind: 'e', foo: unknown }; ->E : E +>E : { kind: 'e'; foo: unknown; } >kind : "e" >foo : unknown diff --git a/tests/baselines/reference/intersectionReductionStrict.types b/tests/baselines/reference/intersectionReductionStrict.types index db47e9ada3fb7..0859d23785e63 100644 --- a/tests/baselines/reference/intersectionReductionStrict.types +++ b/tests/baselines/reference/intersectionReductionStrict.types @@ -31,7 +31,7 @@ type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never >sym1 : unique symbol type T10 = string & ('a' | 'b'); // 'a' | 'b' ->T10 : T10 +>T10 : "a" | "b" type T11 = (string | number) & ('a' | 10); // 'a' | 10 >T11 : "a" | 10 @@ -61,7 +61,7 @@ type N7 = void & string; >N7 : never type X = { x: string }; ->X : X +>X : { x: string; } >x : string type X1 = X | 'a' & 'b'; @@ -89,17 +89,17 @@ type X7 = X | void & string; >X7 : X type A = { kind: 'a', foo: string }; ->A : A +>A : { kind: 'a'; foo: string; } >kind : "a" >foo : string type B = { kind: 'b', foo: number }; ->B : B +>B : { kind: 'b'; foo: number; } >kind : "b" >foo : number type C = { kind: 'c', foo: number }; ->C : C +>C : { kind: 'c'; foo: number; } >kind : "c" >foo : number @@ -143,7 +143,7 @@ type K1 = keyof (A & B); // string | number | symbol >K1 : string | number | symbol type K2 = keyof A | keyof B; // 'kind' | 'foo' ->K2 : K2 +>K2 : "kind" | "foo" type Merge1 = { [P in keyof (T & U)]: P extends keyof T ? T[P] : U[P & keyof U] } >Merge1 : Merge1 @@ -159,14 +159,14 @@ type M1 = { a: 1, b: 2 } & { a: 2, c: 3 }; // never >c : 3 type M2 = Merge1<{ a: 1, b: 2 }, { a: 2, c: 3 }>; // {} ->M2 : M2 +>M2 : {} >a : 1 >b : 2 >a : 2 >c : 3 type M3 = Merge2<{ a: 1, b: 2 }, { a: 2, c: 3 }>; // { a: 1, b: 2, c: 3 } ->M3 : M3 +>M3 : { a: 1; b: 2; c: 3; } >a : 1 >b : 2 >a : 2 diff --git a/tests/baselines/reference/intersectionThisTypes.types b/tests/baselines/reference/intersectionThisTypes.types index 5814099104365..36babb7bacefd 100644 --- a/tests/baselines/reference/intersectionThisTypes.types +++ b/tests/baselines/reference/intersectionThisTypes.types @@ -16,10 +16,10 @@ interface Thing2 { } type Thing3 = Thing1 & Thing2; ->Thing3 : Thing3 +>Thing3 : Thing1 & Thing2 type Thing4 = Thing3 & string[]; ->Thing4 : Thing4 +>Thing4 : Thing1 & Thing2 & string[] function f1(t: Thing3) { >f1 : (t: Thing3) => void diff --git a/tests/baselines/reference/intersectionTypeInference3.types b/tests/baselines/reference/intersectionTypeInference3.types index 173a882312776..27e65f7684ad6 100644 --- a/tests/baselines/reference/intersectionTypeInference3.types +++ b/tests/baselines/reference/intersectionTypeInference3.types @@ -13,7 +13,7 @@ type Nominal = Type & { }; type A = Nominal<'A', string>; ->A : A +>A : string & { [Symbol.species]: "A"; } declare const a: Set; >a : Set diff --git a/tests/baselines/reference/intersectionTypeMembers.types b/tests/baselines/reference/intersectionTypeMembers.types index a48e05243d84e..9ff067f0b7fa0 100644 --- a/tests/baselines/reference/intersectionTypeMembers.types +++ b/tests/baselines/reference/intersectionTypeMembers.types @@ -75,11 +75,11 @@ xyz.x.c = "hello"; >"hello" : "hello" type F1 = (x: string) => string; ->F1 : F1 +>F1 : (x: string) => string >x : string type F2 = (x: number) => number; ->F2 : F2 +>F2 : (x: number) => number >x : number var f: F1 & F2; diff --git a/tests/baselines/reference/intersectionTypeNormalization.types b/tests/baselines/reference/intersectionTypeNormalization.types index c6e5f6dbaf561..6f2f4e35cb13c 100644 --- a/tests/baselines/reference/intersectionTypeNormalization.types +++ b/tests/baselines/reference/intersectionTypeNormalization.types @@ -13,13 +13,13 @@ interface D { d: string } // Identical ways of writing the same type type X1 = (A | B) & (C | D); ->X1 : X1 +>X1 : (A | B) & (C | D) type X2 = A & (C | D) | B & (C | D) ->X2 : X2 +>X2 : (A & (C | D)) | (B & (C | D)) type X3 = A & C | A & D | B & C | B & D; ->X3 : X3 +>X3 : (A & C) | (A & D) | (B & C) | (B & D) var x: X1; >x : X1 @@ -38,13 +38,13 @@ interface Y { y: string } // Identical ways of writing the same type type Y1 = (A | X & Y) & (C | D); ->Y1 : Y1 +>Y1 : (A | (X & Y)) & (C | D) type Y2 = A & (C | D) | X & Y & (C | D) ->Y2 : Y2 +>Y2 : (A & (C | D)) | (X & Y & (C | D)) type Y3 = A & C | A & D | X & Y & C | X & Y & D; ->Y3 : Y3 +>Y3 : (A & C) | (A & D) | (X & Y & C) | (X & Y & D) var y: Y1; >y : Y1 @@ -63,16 +63,16 @@ interface N { n: string } // Identical ways of writing the same type type Z1 = (A | X & (M | N)) & (C | D); ->Z1 : Z1 +>Z1 : (A | (X & (M | N))) & (C | D) type Z2 = A & (C | D) | X & (M | N) & (C | D) ->Z2 : Z2 +>Z2 : (A & (C | D)) | (X & (M | N) & (C | D)) type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; ->Z3 : Z3 +>Z3 : (A & C) | (A & D) | (X & (M | N) & C) | (X & (M | N) & D) type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; ->Z4 : Z4 +>Z4 : (A & C) | (A & D) | (X & M & C) | (X & M & D) | (X & N & C) | (X & N & D) var z: Z1; >z : Z1 @@ -89,14 +89,14 @@ var z: Z4; // Repro from #9919 type ToString = { ->ToString : ToString +>ToString : { toString(): string; } toString(): string; >toString : () => string } type BoxedValue = { kind: 'int', num: number } ->BoxedValue : BoxedValue +>BoxedValue : { kind: 'int'; num: number; } | { kind: 'string'; str: string; } >kind : "int" >num : number @@ -105,10 +105,10 @@ type BoxedValue = { kind: 'int', num: number } >str : string type IntersectionFail = BoxedValue & ToString ->IntersectionFail : IntersectionFail +>IntersectionFail : BoxedValue & ToString type IntersectionInline = { kind: 'int', num: number } & ToString ->IntersectionInline : IntersectionInline +>IntersectionInline : ({ kind: 'int'; num: number; } & ToString) | ({ kind: 'string'; str: string; } & ToString) >kind : "int" >num : number @@ -198,11 +198,11 @@ namespace enums { >c211 : C.c211 } export type Genre = A | B | C; ->Genre : Genre +>Genre : A | B | C } type Foo = { ->Foo : Foo +>Foo : { genreId: enums.Genre; } genreId: enums.Genre; >genreId : enums.Genre @@ -211,7 +211,7 @@ type Foo = { }; type Bar = { ->Bar : Bar +>Bar : { genreId: enums.Genre; } genreId: enums.Genre; >genreId : enums.Genre @@ -220,7 +220,7 @@ type Bar = { }; type FooBar = Foo & Bar; ->FooBar : FooBar +>FooBar : Foo & Bar function foo(so: any) { >foo : (so: any) => enums.Genre diff --git a/tests/baselines/reference/intersectionTypeOverloading.types b/tests/baselines/reference/intersectionTypeOverloading.types index c906b38f5df43..dfaba566255d6 100644 --- a/tests/baselines/reference/intersectionTypeOverloading.types +++ b/tests/baselines/reference/intersectionTypeOverloading.types @@ -3,11 +3,11 @@ // overload resolution type F = (s: string) => string; ->F : F +>F : (s: string) => string >s : string type G = (x: any) => any; ->G : G +>G : (x: any) => any >x : any var fg: F & G; diff --git a/tests/baselines/reference/intersectionTypeWithLeadingOperator.types b/tests/baselines/reference/intersectionTypeWithLeadingOperator.types index 826da4d8c51de..6f41770f483ef 100644 --- a/tests/baselines/reference/intersectionTypeWithLeadingOperator.types +++ b/tests/baselines/reference/intersectionTypeWithLeadingOperator.types @@ -3,7 +3,7 @@ type A = & string; >A : string type B = ->B : B +>B : { foo: string; } & { bar: number; } & { foo: string } >foo : string @@ -12,7 +12,7 @@ type B = >bar : number type C = [& { foo: 1 } & { bar: 2 }, & { foo: 3 } & { bar: 4 }]; ->C : C +>C : [{ foo: 1; } & { bar: 2; }, { foo: 3; } & { bar: 4; }] >foo : 1 >bar : 2 >foo : 3 diff --git a/tests/baselines/reference/intersectionWithConflictingPrivates.types b/tests/baselines/reference/intersectionWithConflictingPrivates.types index 62861bb4ec597..d7f8e4a9dedaa 100644 --- a/tests/baselines/reference/intersectionWithConflictingPrivates.types +++ b/tests/baselines/reference/intersectionWithConflictingPrivates.types @@ -138,7 +138,7 @@ class Foo { } private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) { ->bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {} | undefined) => Promise +>bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) => Promise >node : CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode >options : {} | undefined diff --git a/tests/baselines/reference/intersectionWithIndexSignatures.types b/tests/baselines/reference/intersectionWithIndexSignatures.types index c04a1c93bcbc7..21d2d72f0ca4d 100644 --- a/tests/baselines/reference/intersectionWithIndexSignatures.types +++ b/tests/baselines/reference/intersectionWithIndexSignatures.types @@ -1,10 +1,10 @@ === tests/cases/conformance/types/intersection/intersectionWithIndexSignatures.ts === type A = { a: string }; ->A : A +>A : { a: string; } >a : string type B = { b: string }; ->B : B +>B : { b: string; } >b : string declare let sa1: { x: A & B }; @@ -65,7 +65,7 @@ type constr = { [K in keyof Source]: string } & Pickconstr : constr type s = constr<{}, { [key: string]: { a: string } }>; ->s : s +>s : {} & Pick<{ [key: string]: { a: string; }; }, string | number> >key : string >a : string diff --git a/tests/baselines/reference/intersectionsAndEmptyObjects.types b/tests/baselines/reference/intersectionsAndEmptyObjects.types index 1c73b23c07d5c..5459f614a89ed 100644 --- a/tests/baselines/reference/intersectionsAndEmptyObjects.types +++ b/tests/baselines/reference/intersectionsAndEmptyObjects.types @@ -3,15 +3,15 @@ // that contain other object types type A = { a: number }; ->A : A +>A : { a: number; } >a : number type B = { b: string }; ->B : B +>B : { b: string; } >b : string type C = {}; ->C : C +>C : {} let x01: A & B; >x01 : A & B @@ -61,7 +61,7 @@ let x14: A & B & C & D & E; // Repro from #20225 type Dictionary = { [name: string]: string }; ->Dictionary : Dictionary +>Dictionary : { [name: string]: string; } >name : string const intersectDictionaries = ( @@ -177,7 +177,7 @@ type choicesIMyChoiceList : IMyChoiceList +>IMyChoiceList : { car: true; } car: true >car : true @@ -186,7 +186,7 @@ type IMyChoiceList = { }; type IUnknownChoiceList = {}; ->IUnknownChoiceList : IUnknownChoiceList +>IUnknownChoiceList : {} var defaultChoices: choices<{}>; >defaultChoices : { shoes: boolean; food: boolean; } @@ -209,12 +209,12 @@ var unknownChoicesAndEmpty: choices; // Repro from #38672 type Foo1 = { x: string } & { [x: number]: Foo1 }; ->Foo1 : Foo1 +>Foo1 : { x: string; } & { [x: number]: Foo1; } >x : string >x : number type Foo2 = { x: string } & { [K in number]: Foo2 }; ->Foo2 : Foo2 +>Foo2 : { x: string; } & { [x: number]: Foo2; } >x : string // Repro from #40239 diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.types b/tests/baselines/reference/intersectionsAndOptionalProperties.types index 98bc85c7e4299..f00ab71e13f3c 100644 --- a/tests/baselines/reference/intersectionsAndOptionalProperties.types +++ b/tests/baselines/reference/intersectionsAndOptionalProperties.types @@ -37,7 +37,7 @@ interface To { } type From = { field: null } & Omit; ->From : From +>From : { field: null; } & Omit >field : null >null : null diff --git a/tests/baselines/reference/intersectionsAndReadonlyProperties.types b/tests/baselines/reference/intersectionsAndReadonlyProperties.types index a5130d48111b5..8e1bd8c16d22b 100644 --- a/tests/baselines/reference/intersectionsAndReadonlyProperties.types +++ b/tests/baselines/reference/intersectionsAndReadonlyProperties.types @@ -1,7 +1,7 @@ === tests/cases/compiler/intersectionsAndReadonlyProperties.ts === // readonly and non-readonly type Intersection1 = { readonly a: number } & { a: number }; ->Intersection1 : Intersection1 +>Intersection1 : { readonly a: number; } & { a: number; } >a : number >a : number @@ -17,7 +17,7 @@ i1.a = 2; // getter and setter type Intersection2 = { get a(): number } & { set a(v: number) }; ->Intersection2 : Intersection2 +>Intersection2 : { readonly a: number; } & { a: number; } >a : number >a : number >v : number @@ -34,7 +34,7 @@ i2.a = 2; // assignment to an all read-only property should still be disallowed type IntersectionAllReadonly = { readonly a: number } & { get a(): number }; ->IntersectionAllReadonly : IntersectionAllReadonly +>IntersectionAllReadonly : { readonly a: number; } & { readonly a: number; } >a : number >a : number diff --git a/tests/baselines/reference/intraExpressionInferences.errors.txt b/tests/baselines/reference/intraExpressionInferences.errors.txt index e4d3548c45740..745cd9b9e426c 100644 --- a/tests/baselines/reference/intraExpressionInferences.errors.txt +++ b/tests/baselines/reference/intraExpressionInferences.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts(123,5): error TS2322: Type '(inputs: Unwrap<{ num: Wrapper; str: Wrapper; }>) => { bool: any; str: number; }' is not assignable to type '(inputs: Unwrap<{ num: Wrapper; str: Wrapper; }>) => Unwrap<{ bool: Wrapper; str: Wrapper; }>'. +tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts(131,5): error TS2322: Type '(inputs: Unwrap<{ num: Wrapper; str: Wrapper; }>) => { bool: any; str: number; }' is not assignable to type '(inputs: Unwrap<{ num: Wrapper; str: Wrapper; }>) => Unwrap<{ bool: Wrapper; str: Wrapper; }>'. Call signature return types '{ bool: any; str: number; }' and 'Unwrap<{ bool: Wrapper; str: Wrapper; }>' are incompatible. The types of 'str' are incompatible between these types. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts(125,26): error TS2339: Property 'nonexistent' does not exist on type 'Unwrap<{ num: Wrapper; str: Wrapper; }>'. +tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts(133,26): error TS2339: Property 'nonexistent' does not exist on type 'Unwrap<{ num: Wrapper; str: Wrapper; }>'. ==== tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts (2 errors) ==== @@ -97,6 +97,14 @@ tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInf } }); + test({ + a: () => 0, + b: (a) => a, + c: (b) => { + const x: number = b; + } + }); + // Repro from #41712 class Wrapper { @@ -134,7 +142,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInf !!! error TS2322: Call signature return types '{ bool: any; str: number; }' and 'Unwrap<{ bool: Wrapper; str: Wrapper; }>' are incompatible. !!! error TS2322: The types of 'str' are incompatible between these types. !!! error TS2322: Type 'number' is not assignable to type 'string'. -!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts:105:5: The expected type comes from property 'map' which is declared here on type 'MappingComponent<{ num: Wrapper; str: Wrapper; }, { bool: Wrapper; str: Wrapper; }>' +!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts:113:5: The expected type comes from property 'map' which is declared here on type 'MappingComponent<{ num: Wrapper; str: Wrapper; }, { bool: Wrapper; str: Wrapper; }>' return { bool: inputs.nonexistent, ~~~~~~~~~~~ @@ -189,4 +197,19 @@ tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInf fetch: (params: Params, foo) => 123, map: (number) => String(number) }); + + // Repro from #45255 + + declare const branch: + (_: { test: T, if: (t: T) => t is U, then: (u: U) => void }) => void + + declare const x: "a" | "b" + + branch({ + test: x, + if: (t): t is "a" => t === "a", + then: u => { + let test1: "a" = u + } + }) \ No newline at end of file diff --git a/tests/baselines/reference/intraExpressionInferences.js b/tests/baselines/reference/intraExpressionInferences.js index 20647b46897cf..b2ce11d0d9311 100644 --- a/tests/baselines/reference/intraExpressionInferences.js +++ b/tests/baselines/reference/intraExpressionInferences.js @@ -90,6 +90,14 @@ test({ } }); +test({ + a: () => 0, + b: (a) => a, + c: (b) => { + const x: number = b; + } +}); + // Repro from #41712 class Wrapper { @@ -174,6 +182,21 @@ example({ fetch: (params: Params, foo) => 123, map: (number) => String(number) }); + +// Repro from #45255 + +declare const branch: + (_: { test: T, if: (t: T) => t is U, then: (u: U) => void }) => void + +declare const x: "a" | "b" + +branch({ + test: x, + if: (t): t is "a" => t === "a", + then: u => { + let test1: "a" = u + } +}) //// [intraExpressionInferences.js] @@ -228,6 +251,13 @@ test({ var x = b; } }); +test({ + a: function () { return 0; }, + b: function (a) { return a; }, + c: function (b) { + var x = b; + } +}); // Repro from #41712 var Wrapper = /** @class */ (function () { function Wrapper() { @@ -279,6 +309,13 @@ example({ fetch: function (params, foo) { return 123; }, map: function (number) { return String(number); } }); +branch({ + test: x, + "if": function (t) { return t === "a"; }, + then: function (u) { + var test1 = u; + } +}); //// [intraExpressionInferences.d.ts] @@ -340,3 +377,9 @@ interface Params { one: number; two: string; } +declare const branch: (_: { + test: T; + if: (t: T) => t is U; + then: (u: U) => void; +}) => void; +declare const x: "a" | "b"; diff --git a/tests/baselines/reference/intraExpressionInferences.symbols b/tests/baselines/reference/intraExpressionInferences.symbols index 05887ee317b01..6651221146f12 100644 --- a/tests/baselines/reference/intraExpressionInferences.symbols +++ b/tests/baselines/reference/intraExpressionInferences.symbols @@ -264,119 +264,140 @@ test({ } }); +test({ +>test : Symbol(test, Decl(intraExpressionInferences.ts, 79, 2)) + + a: () => 0, +>a : Symbol(a, Decl(intraExpressionInferences.ts, 91, 6)) + + b: (a) => a, +>b : Symbol(b, Decl(intraExpressionInferences.ts, 92, 15)) +>a : Symbol(a, Decl(intraExpressionInferences.ts, 93, 8)) +>a : Symbol(a, Decl(intraExpressionInferences.ts, 93, 8)) + + c: (b) => { +>c : Symbol(c, Decl(intraExpressionInferences.ts, 93, 16)) +>b : Symbol(b, Decl(intraExpressionInferences.ts, 94, 8)) + + const x: number = b; +>x : Symbol(x, Decl(intraExpressionInferences.ts, 95, 13)) +>b : Symbol(b, Decl(intraExpressionInferences.ts, 94, 8)) + } +}); + // Repro from #41712 class Wrapper { ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 93, 14)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 101, 14)) public value?: T; ->value : Symbol(Wrapper.value, Decl(intraExpressionInferences.ts, 93, 24)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 93, 14)) +>value : Symbol(Wrapper.value, Decl(intraExpressionInferences.ts, 101, 24)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 101, 14)) } type WrappedMap = Record; ->WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 95, 1)) +>WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 103, 1)) >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) type Unwrap = { ->Unwrap : Symbol(Unwrap, Decl(intraExpressionInferences.ts, 97, 42)) ->D : Symbol(D, Decl(intraExpressionInferences.ts, 98, 12)) ->WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 95, 1)) +>Unwrap : Symbol(Unwrap, Decl(intraExpressionInferences.ts, 105, 42)) +>D : Symbol(D, Decl(intraExpressionInferences.ts, 106, 12)) +>WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 103, 1)) [K in keyof D]: D[K] extends Wrapper ? T : never; ->K : Symbol(K, Decl(intraExpressionInferences.ts, 99, 5)) ->D : Symbol(D, Decl(intraExpressionInferences.ts, 98, 12)) ->D : Symbol(D, Decl(intraExpressionInferences.ts, 98, 12)) ->K : Symbol(K, Decl(intraExpressionInferences.ts, 99, 5)) ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 99, 46)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 99, 46)) +>K : Symbol(K, Decl(intraExpressionInferences.ts, 107, 5)) +>D : Symbol(D, Decl(intraExpressionInferences.ts, 106, 12)) +>D : Symbol(D, Decl(intraExpressionInferences.ts, 106, 12)) +>K : Symbol(K, Decl(intraExpressionInferences.ts, 107, 5)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 107, 46)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 107, 46)) }; type MappingComponent = { ->MappingComponent : Symbol(MappingComponent, Decl(intraExpressionInferences.ts, 100, 2)) ->I : Symbol(I, Decl(intraExpressionInferences.ts, 102, 22)) ->WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 95, 1)) ->O : Symbol(O, Decl(intraExpressionInferences.ts, 102, 43)) ->WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 95, 1)) +>MappingComponent : Symbol(MappingComponent, Decl(intraExpressionInferences.ts, 108, 2)) +>I : Symbol(I, Decl(intraExpressionInferences.ts, 110, 22)) +>WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 103, 1)) +>O : Symbol(O, Decl(intraExpressionInferences.ts, 110, 43)) +>WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 103, 1)) setup(): { inputs: I; outputs: O }; ->setup : Symbol(setup, Decl(intraExpressionInferences.ts, 102, 69)) ->inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 103, 14)) ->I : Symbol(I, Decl(intraExpressionInferences.ts, 102, 22)) ->outputs : Symbol(outputs, Decl(intraExpressionInferences.ts, 103, 25)) ->O : Symbol(O, Decl(intraExpressionInferences.ts, 102, 43)) +>setup : Symbol(setup, Decl(intraExpressionInferences.ts, 110, 69)) +>inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 111, 14)) +>I : Symbol(I, Decl(intraExpressionInferences.ts, 110, 22)) +>outputs : Symbol(outputs, Decl(intraExpressionInferences.ts, 111, 25)) +>O : Symbol(O, Decl(intraExpressionInferences.ts, 110, 43)) map?: (inputs: Unwrap) => Unwrap; ->map : Symbol(map, Decl(intraExpressionInferences.ts, 103, 39)) ->inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 104, 11)) ->Unwrap : Symbol(Unwrap, Decl(intraExpressionInferences.ts, 97, 42)) ->I : Symbol(I, Decl(intraExpressionInferences.ts, 102, 22)) ->Unwrap : Symbol(Unwrap, Decl(intraExpressionInferences.ts, 97, 42)) ->O : Symbol(O, Decl(intraExpressionInferences.ts, 102, 43)) +>map : Symbol(map, Decl(intraExpressionInferences.ts, 111, 39)) +>inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 112, 11)) +>Unwrap : Symbol(Unwrap, Decl(intraExpressionInferences.ts, 105, 42)) +>I : Symbol(I, Decl(intraExpressionInferences.ts, 110, 22)) +>Unwrap : Symbol(Unwrap, Decl(intraExpressionInferences.ts, 105, 42)) +>O : Symbol(O, Decl(intraExpressionInferences.ts, 110, 43)) }; declare function createMappingComponent(def: MappingComponent): void; ->createMappingComponent : Symbol(createMappingComponent, Decl(intraExpressionInferences.ts, 105, 2)) ->I : Symbol(I, Decl(intraExpressionInferences.ts, 107, 40)) ->WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 95, 1)) ->O : Symbol(O, Decl(intraExpressionInferences.ts, 107, 61)) ->WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 95, 1)) ->def : Symbol(def, Decl(intraExpressionInferences.ts, 107, 84)) ->MappingComponent : Symbol(MappingComponent, Decl(intraExpressionInferences.ts, 100, 2)) ->I : Symbol(I, Decl(intraExpressionInferences.ts, 107, 40)) ->O : Symbol(O, Decl(intraExpressionInferences.ts, 107, 61)) +>createMappingComponent : Symbol(createMappingComponent, Decl(intraExpressionInferences.ts, 113, 2)) +>I : Symbol(I, Decl(intraExpressionInferences.ts, 115, 40)) +>WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 103, 1)) +>O : Symbol(O, Decl(intraExpressionInferences.ts, 115, 61)) +>WrappedMap : Symbol(WrappedMap, Decl(intraExpressionInferences.ts, 103, 1)) +>def : Symbol(def, Decl(intraExpressionInferences.ts, 115, 84)) +>MappingComponent : Symbol(MappingComponent, Decl(intraExpressionInferences.ts, 108, 2)) +>I : Symbol(I, Decl(intraExpressionInferences.ts, 115, 40)) +>O : Symbol(O, Decl(intraExpressionInferences.ts, 115, 61)) createMappingComponent({ ->createMappingComponent : Symbol(createMappingComponent, Decl(intraExpressionInferences.ts, 105, 2)) +>createMappingComponent : Symbol(createMappingComponent, Decl(intraExpressionInferences.ts, 113, 2)) setup() { ->setup : Symbol(setup, Decl(intraExpressionInferences.ts, 109, 24)) +>setup : Symbol(setup, Decl(intraExpressionInferences.ts, 117, 24)) return { inputs: { ->inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 111, 16)) +>inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 119, 16)) num: new Wrapper(), ->num : Symbol(num, Decl(intraExpressionInferences.ts, 112, 21)) ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) +>num : Symbol(num, Decl(intraExpressionInferences.ts, 120, 21)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) str: new Wrapper() ->str : Symbol(str, Decl(intraExpressionInferences.ts, 113, 43)) ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) +>str : Symbol(str, Decl(intraExpressionInferences.ts, 121, 43)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) }, outputs: { ->outputs : Symbol(outputs, Decl(intraExpressionInferences.ts, 115, 14)) +>outputs : Symbol(outputs, Decl(intraExpressionInferences.ts, 123, 14)) bool: new Wrapper(), ->bool : Symbol(bool, Decl(intraExpressionInferences.ts, 116, 22)) ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) +>bool : Symbol(bool, Decl(intraExpressionInferences.ts, 124, 22)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) str: new Wrapper() ->str : Symbol(str, Decl(intraExpressionInferences.ts, 117, 45)) ->Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 89, 3)) +>str : Symbol(str, Decl(intraExpressionInferences.ts, 125, 45)) +>Wrapper : Symbol(Wrapper, Decl(intraExpressionInferences.ts, 97, 3)) } }; }, map(inputs) { ->map : Symbol(map, Decl(intraExpressionInferences.ts, 121, 6)) ->inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 122, 8)) +>map : Symbol(map, Decl(intraExpressionInferences.ts, 129, 6)) +>inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 130, 8)) return { bool: inputs.nonexistent, ->bool : Symbol(bool, Decl(intraExpressionInferences.ts, 123, 16)) ->inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 122, 8)) +>bool : Symbol(bool, Decl(intraExpressionInferences.ts, 131, 16)) +>inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 130, 8)) str: inputs.num, // Causes error ->str : Symbol(str, Decl(intraExpressionInferences.ts, 124, 37)) ->inputs.num : Symbol(num, Decl(intraExpressionInferences.ts, 112, 21)) ->inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 122, 8)) ->num : Symbol(num, Decl(intraExpressionInferences.ts, 112, 21)) +>str : Symbol(str, Decl(intraExpressionInferences.ts, 132, 37)) +>inputs.num : Symbol(num, Decl(intraExpressionInferences.ts, 120, 21)) +>inputs : Symbol(inputs, Decl(intraExpressionInferences.ts, 130, 8)) +>num : Symbol(num, Decl(intraExpressionInferences.ts, 120, 21)) } } }); @@ -384,177 +405,224 @@ createMappingComponent({ // Repro from #48279 function simplified(props: { generator: () => T, receiver: (t: T) => any }) {} ->simplified : Symbol(simplified, Decl(intraExpressionInferences.ts, 128, 3)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 132, 20)) ->props : Symbol(props, Decl(intraExpressionInferences.ts, 132, 23)) ->generator : Symbol(generator, Decl(intraExpressionInferences.ts, 132, 31)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 132, 20)) ->receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 132, 51)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 132, 63)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 132, 20)) +>simplified : Symbol(simplified, Decl(intraExpressionInferences.ts, 136, 3)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 140, 20)) +>props : Symbol(props, Decl(intraExpressionInferences.ts, 140, 23)) +>generator : Symbol(generator, Decl(intraExpressionInferences.ts, 140, 31)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 140, 20)) +>receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 140, 51)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 140, 63)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 140, 20)) function whatIWant(props: { generator: (bob: any) => T, receiver: (t: T) => any }) {} ->whatIWant : Symbol(whatIWant, Decl(intraExpressionInferences.ts, 132, 81)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 134, 19)) ->props : Symbol(props, Decl(intraExpressionInferences.ts, 134, 22)) ->generator : Symbol(generator, Decl(intraExpressionInferences.ts, 134, 30)) ->bob : Symbol(bob, Decl(intraExpressionInferences.ts, 134, 43)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 134, 19)) ->receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 134, 58)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 134, 70)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 134, 19)) +>whatIWant : Symbol(whatIWant, Decl(intraExpressionInferences.ts, 140, 81)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 142, 19)) +>props : Symbol(props, Decl(intraExpressionInferences.ts, 142, 22)) +>generator : Symbol(generator, Decl(intraExpressionInferences.ts, 142, 30)) +>bob : Symbol(bob, Decl(intraExpressionInferences.ts, 142, 43)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 142, 19)) +>receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 142, 58)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 142, 70)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 142, 19)) function nonObject(generator: (bob: any) => T, receiver: (t: T) => any) {} ->nonObject : Symbol(nonObject, Decl(intraExpressionInferences.ts, 134, 88)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 136, 19)) ->generator : Symbol(generator, Decl(intraExpressionInferences.ts, 136, 22)) ->bob : Symbol(bob, Decl(intraExpressionInferences.ts, 136, 34)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 136, 19)) ->receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 136, 49)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 136, 61)) ->T : Symbol(T, Decl(intraExpressionInferences.ts, 136, 19)) +>nonObject : Symbol(nonObject, Decl(intraExpressionInferences.ts, 142, 88)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 144, 19)) +>generator : Symbol(generator, Decl(intraExpressionInferences.ts, 144, 22)) +>bob : Symbol(bob, Decl(intraExpressionInferences.ts, 144, 34)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 144, 19)) +>receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 144, 49)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 144, 61)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 144, 19)) simplified({ generator: () => 123, receiver: (t) => console.log(t + 2) }) ->simplified : Symbol(simplified, Decl(intraExpressionInferences.ts, 128, 3)) ->generator : Symbol(generator, Decl(intraExpressionInferences.ts, 138, 12)) ->receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 138, 34)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 138, 46)) +>simplified : Symbol(simplified, Decl(intraExpressionInferences.ts, 136, 3)) +>generator : Symbol(generator, Decl(intraExpressionInferences.ts, 146, 12)) +>receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 146, 34)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 146, 46)) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 138, 46)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 146, 46)) whatIWant({ generator: (bob) => bob ? 1 : 2, receiver: (t) => console.log(t + 2) }) ->whatIWant : Symbol(whatIWant, Decl(intraExpressionInferences.ts, 132, 81)) ->generator : Symbol(generator, Decl(intraExpressionInferences.ts, 139, 11)) ->bob : Symbol(bob, Decl(intraExpressionInferences.ts, 139, 24)) ->bob : Symbol(bob, Decl(intraExpressionInferences.ts, 139, 24)) ->receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 139, 44)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 139, 56)) +>whatIWant : Symbol(whatIWant, Decl(intraExpressionInferences.ts, 140, 81)) +>generator : Symbol(generator, Decl(intraExpressionInferences.ts, 147, 11)) +>bob : Symbol(bob, Decl(intraExpressionInferences.ts, 147, 24)) +>bob : Symbol(bob, Decl(intraExpressionInferences.ts, 147, 24)) +>receiver : Symbol(receiver, Decl(intraExpressionInferences.ts, 147, 44)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 147, 56)) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 139, 56)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 147, 56)) nonObject((bob) => bob ? 1 : 2, (t) => console.log(t + 2)) ->nonObject : Symbol(nonObject, Decl(intraExpressionInferences.ts, 134, 88)) ->bob : Symbol(bob, Decl(intraExpressionInferences.ts, 140, 11)) ->bob : Symbol(bob, Decl(intraExpressionInferences.ts, 140, 11)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 140, 33)) +>nonObject : Symbol(nonObject, Decl(intraExpressionInferences.ts, 142, 88)) +>bob : Symbol(bob, Decl(intraExpressionInferences.ts, 148, 11)) +>bob : Symbol(bob, Decl(intraExpressionInferences.ts, 148, 11)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 148, 33)) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->t : Symbol(t, Decl(intraExpressionInferences.ts, 140, 33)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 148, 33)) // Repro from #48466 interface Opts { ->Opts : Symbol(Opts, Decl(intraExpressionInferences.ts, 140, 58)) ->TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 144, 15)) ->TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 144, 23)) ->TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 144, 30)) +>Opts : Symbol(Opts, Decl(intraExpressionInferences.ts, 148, 58)) +>TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 152, 15)) +>TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 152, 23)) +>TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 152, 30)) fetch: (params: TParams, foo: number) => TDone, ->fetch : Symbol(Opts.fetch, Decl(intraExpressionInferences.ts, 144, 41)) ->params : Symbol(params, Decl(intraExpressionInferences.ts, 145, 12)) ->TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 144, 15)) ->foo : Symbol(foo, Decl(intraExpressionInferences.ts, 145, 28)) ->TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 144, 23)) +>fetch : Symbol(Opts.fetch, Decl(intraExpressionInferences.ts, 152, 41)) +>params : Symbol(params, Decl(intraExpressionInferences.ts, 153, 12)) +>TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 152, 15)) +>foo : Symbol(foo, Decl(intraExpressionInferences.ts, 153, 28)) +>TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 152, 23)) map: (data: TDone) => TMapped ->map : Symbol(Opts.map, Decl(intraExpressionInferences.ts, 145, 51)) ->data : Symbol(data, Decl(intraExpressionInferences.ts, 146, 10)) ->TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 144, 23)) ->TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 144, 30)) +>map : Symbol(Opts.map, Decl(intraExpressionInferences.ts, 153, 51)) +>data : Symbol(data, Decl(intraExpressionInferences.ts, 154, 10)) +>TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 152, 23)) +>TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 152, 30)) } function example(options: Opts) { ->example : Symbol(example, Decl(intraExpressionInferences.ts, 147, 1)) ->TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 149, 17)) ->TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 149, 25)) ->TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 149, 32)) ->options : Symbol(options, Decl(intraExpressionInferences.ts, 149, 42)) ->Opts : Symbol(Opts, Decl(intraExpressionInferences.ts, 140, 58)) ->TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 149, 17)) ->TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 149, 25)) ->TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 149, 32)) +>example : Symbol(example, Decl(intraExpressionInferences.ts, 155, 1)) +>TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 157, 17)) +>TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 157, 25)) +>TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 157, 32)) +>options : Symbol(options, Decl(intraExpressionInferences.ts, 157, 42)) +>Opts : Symbol(Opts, Decl(intraExpressionInferences.ts, 148, 58)) +>TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 157, 17)) +>TDone : Symbol(TDone, Decl(intraExpressionInferences.ts, 157, 25)) +>TMapped : Symbol(TMapped, Decl(intraExpressionInferences.ts, 157, 32)) return (params: TParams) => { ->params : Symbol(params, Decl(intraExpressionInferences.ts, 150, 12)) ->TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 149, 17)) +>params : Symbol(params, Decl(intraExpressionInferences.ts, 158, 12)) +>TParams : Symbol(TParams, Decl(intraExpressionInferences.ts, 157, 17)) const data = options.fetch(params, 123) ->data : Symbol(data, Decl(intraExpressionInferences.ts, 151, 13)) ->options.fetch : Symbol(Opts.fetch, Decl(intraExpressionInferences.ts, 144, 41)) ->options : Symbol(options, Decl(intraExpressionInferences.ts, 149, 42)) ->fetch : Symbol(Opts.fetch, Decl(intraExpressionInferences.ts, 144, 41)) ->params : Symbol(params, Decl(intraExpressionInferences.ts, 150, 12)) +>data : Symbol(data, Decl(intraExpressionInferences.ts, 159, 13)) +>options.fetch : Symbol(Opts.fetch, Decl(intraExpressionInferences.ts, 152, 41)) +>options : Symbol(options, Decl(intraExpressionInferences.ts, 157, 42)) +>fetch : Symbol(Opts.fetch, Decl(intraExpressionInferences.ts, 152, 41)) +>params : Symbol(params, Decl(intraExpressionInferences.ts, 158, 12)) return options.map(data) ->options.map : Symbol(Opts.map, Decl(intraExpressionInferences.ts, 145, 51)) ->options : Symbol(options, Decl(intraExpressionInferences.ts, 149, 42)) ->map : Symbol(Opts.map, Decl(intraExpressionInferences.ts, 145, 51)) ->data : Symbol(data, Decl(intraExpressionInferences.ts, 151, 13)) +>options.map : Symbol(Opts.map, Decl(intraExpressionInferences.ts, 153, 51)) +>options : Symbol(options, Decl(intraExpressionInferences.ts, 157, 42)) +>map : Symbol(Opts.map, Decl(intraExpressionInferences.ts, 153, 51)) +>data : Symbol(data, Decl(intraExpressionInferences.ts, 159, 13)) } } interface Params { ->Params : Symbol(Params, Decl(intraExpressionInferences.ts, 154, 1)) +>Params : Symbol(Params, Decl(intraExpressionInferences.ts, 162, 1)) one: number ->one : Symbol(Params.one, Decl(intraExpressionInferences.ts, 156, 18)) +>one : Symbol(Params.one, Decl(intraExpressionInferences.ts, 164, 18)) two: string ->two : Symbol(Params.two, Decl(intraExpressionInferences.ts, 157, 15)) +>two : Symbol(Params.two, Decl(intraExpressionInferences.ts, 165, 15)) } example({ ->example : Symbol(example, Decl(intraExpressionInferences.ts, 147, 1)) +>example : Symbol(example, Decl(intraExpressionInferences.ts, 155, 1)) fetch: (params: Params) => 123, ->fetch : Symbol(fetch, Decl(intraExpressionInferences.ts, 161, 9)) ->params : Symbol(params, Decl(intraExpressionInferences.ts, 162, 12)) ->Params : Symbol(Params, Decl(intraExpressionInferences.ts, 154, 1)) +>fetch : Symbol(fetch, Decl(intraExpressionInferences.ts, 169, 9)) +>params : Symbol(params, Decl(intraExpressionInferences.ts, 170, 12)) +>Params : Symbol(Params, Decl(intraExpressionInferences.ts, 162, 1)) map: (number) => String(number) ->map : Symbol(map, Decl(intraExpressionInferences.ts, 162, 35)) ->number : Symbol(number, Decl(intraExpressionInferences.ts, 163, 10)) +>map : Symbol(map, Decl(intraExpressionInferences.ts, 170, 35)) +>number : Symbol(number, Decl(intraExpressionInferences.ts, 171, 10)) >String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->number : Symbol(number, Decl(intraExpressionInferences.ts, 163, 10)) +>number : Symbol(number, Decl(intraExpressionInferences.ts, 171, 10)) }); example({ ->example : Symbol(example, Decl(intraExpressionInferences.ts, 147, 1)) +>example : Symbol(example, Decl(intraExpressionInferences.ts, 155, 1)) fetch: (params: Params, foo: number) => 123, ->fetch : Symbol(fetch, Decl(intraExpressionInferences.ts, 166, 9)) ->params : Symbol(params, Decl(intraExpressionInferences.ts, 167, 12)) ->Params : Symbol(Params, Decl(intraExpressionInferences.ts, 154, 1)) ->foo : Symbol(foo, Decl(intraExpressionInferences.ts, 167, 27)) +>fetch : Symbol(fetch, Decl(intraExpressionInferences.ts, 174, 9)) +>params : Symbol(params, Decl(intraExpressionInferences.ts, 175, 12)) +>Params : Symbol(Params, Decl(intraExpressionInferences.ts, 162, 1)) +>foo : Symbol(foo, Decl(intraExpressionInferences.ts, 175, 27)) map: (number) => String(number) ->map : Symbol(map, Decl(intraExpressionInferences.ts, 167, 48)) ->number : Symbol(number, Decl(intraExpressionInferences.ts, 168, 10)) +>map : Symbol(map, Decl(intraExpressionInferences.ts, 175, 48)) +>number : Symbol(number, Decl(intraExpressionInferences.ts, 176, 10)) >String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->number : Symbol(number, Decl(intraExpressionInferences.ts, 168, 10)) +>number : Symbol(number, Decl(intraExpressionInferences.ts, 176, 10)) }); example({ ->example : Symbol(example, Decl(intraExpressionInferences.ts, 147, 1)) +>example : Symbol(example, Decl(intraExpressionInferences.ts, 155, 1)) fetch: (params: Params, foo) => 123, ->fetch : Symbol(fetch, Decl(intraExpressionInferences.ts, 171, 9)) ->params : Symbol(params, Decl(intraExpressionInferences.ts, 172, 12)) ->Params : Symbol(Params, Decl(intraExpressionInferences.ts, 154, 1)) ->foo : Symbol(foo, Decl(intraExpressionInferences.ts, 172, 27)) +>fetch : Symbol(fetch, Decl(intraExpressionInferences.ts, 179, 9)) +>params : Symbol(params, Decl(intraExpressionInferences.ts, 180, 12)) +>Params : Symbol(Params, Decl(intraExpressionInferences.ts, 162, 1)) +>foo : Symbol(foo, Decl(intraExpressionInferences.ts, 180, 27)) map: (number) => String(number) ->map : Symbol(map, Decl(intraExpressionInferences.ts, 172, 40)) ->number : Symbol(number, Decl(intraExpressionInferences.ts, 173, 10)) +>map : Symbol(map, Decl(intraExpressionInferences.ts, 180, 40)) +>number : Symbol(number, Decl(intraExpressionInferences.ts, 181, 10)) >String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->number : Symbol(number, Decl(intraExpressionInferences.ts, 173, 10)) +>number : Symbol(number, Decl(intraExpressionInferences.ts, 181, 10)) }); +// Repro from #45255 + +declare const branch: +>branch : Symbol(branch, Decl(intraExpressionInferences.ts, 186, 13)) + + (_: { test: T, if: (t: T) => t is U, then: (u: U) => void }) => void +>T : Symbol(T, Decl(intraExpressionInferences.ts, 187, 3)) +>U : Symbol(U, Decl(intraExpressionInferences.ts, 187, 5)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 187, 3)) +>_ : Symbol(_, Decl(intraExpressionInferences.ts, 187, 19)) +>test : Symbol(test, Decl(intraExpressionInferences.ts, 187, 23)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 187, 3)) +>if : Symbol(if, Decl(intraExpressionInferences.ts, 187, 32)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 187, 38)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 187, 3)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 187, 38)) +>U : Symbol(U, Decl(intraExpressionInferences.ts, 187, 5)) +>then : Symbol(then, Decl(intraExpressionInferences.ts, 187, 54)) +>u : Symbol(u, Decl(intraExpressionInferences.ts, 187, 62)) +>U : Symbol(U, Decl(intraExpressionInferences.ts, 187, 5)) + +declare const x: "a" | "b" +>x : Symbol(x, Decl(intraExpressionInferences.ts, 189, 13)) + +branch({ +>branch : Symbol(branch, Decl(intraExpressionInferences.ts, 186, 13)) + + test: x, +>test : Symbol(test, Decl(intraExpressionInferences.ts, 191, 8)) +>x : Symbol(x, Decl(intraExpressionInferences.ts, 189, 13)) + + if: (t): t is "a" => t === "a", +>if : Symbol(if, Decl(intraExpressionInferences.ts, 192, 10)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 193, 7)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 193, 7)) +>t : Symbol(t, Decl(intraExpressionInferences.ts, 193, 7)) + + then: u => { +>then : Symbol(then, Decl(intraExpressionInferences.ts, 193, 33)) +>u : Symbol(u, Decl(intraExpressionInferences.ts, 194, 7)) + + let test1: "a" = u +>test1 : Symbol(test1, Decl(intraExpressionInferences.ts, 195, 7)) +>u : Symbol(u, Decl(intraExpressionInferences.ts, 194, 7)) + } +}) + diff --git a/tests/baselines/reference/intraExpressionInferences.types b/tests/baselines/reference/intraExpressionInferences.types index 50a99ac34fe11..87e12e55daef4 100644 --- a/tests/baselines/reference/intraExpressionInferences.types +++ b/tests/baselines/reference/intraExpressionInferences.types @@ -293,6 +293,33 @@ test({ } }); +test({ +>test({ a: () => 0, b: (a) => a, c: (b) => { const x: number = b; }}) : void +>test : (foo: Chain) => void +>{ a: () => 0, b: (a) => a, c: (b) => { const x: number = b; }} : { a: () => number; b: (a: number) => number; c: (b: number) => void; } + + a: () => 0, +>a : () => number +>() => 0 : () => number +>0 : 0 + + b: (a) => a, +>b : (a: number) => number +>(a) => a : (a: number) => number +>a : number +>a : number + + c: (b) => { +>c : (b: number) => void +>(b) => { const x: number = b; } : (b: number) => void +>b : number + + const x: number = b; +>x : number +>b : number + } +}); + // Repro from #41712 class Wrapper { @@ -303,7 +330,7 @@ class Wrapper { } type WrappedMap = Record; ->WrappedMap : WrappedMap +>WrappedMap : { [x: string]: Wrapper; } type Unwrap = { >Unwrap : Unwrap @@ -588,3 +615,47 @@ example({ }); +// Repro from #45255 + +declare const branch: +>branch : (_: { test: T; if: (t: T) => t is U; then: (u: U) => void; }) => void + + (_: { test: T, if: (t: T) => t is U, then: (u: U) => void }) => void +>_ : { test: T; if: (t: T) => t is U; then: (u: U) => void; } +>test : T +>if : (t: T) => t is U +>t : T +>then : (u: U) => void +>u : U + +declare const x: "a" | "b" +>x : "a" | "b" + +branch({ +>branch({ test: x, if: (t): t is "a" => t === "a", then: u => { let test1: "a" = u }}) : void +>branch : (_: { test: T; if: (t: T) => t is U; then: (u: U) => void; }) => void +>{ test: x, if: (t): t is "a" => t === "a", then: u => { let test1: "a" = u }} : { test: "a" | "b"; if: (t: "a" | "b") => t is "a"; then: (u: "a") => void; } + + test: x, +>test : "a" | "b" +>x : "a" | "b" + + if: (t): t is "a" => t === "a", +>if : (t: "a" | "b") => t is "a" +>(t): t is "a" => t === "a" : (t: "a" | "b") => t is "a" +>t : "a" | "b" +>t === "a" : boolean +>t : "a" | "b" +>"a" : "a" + + then: u => { +>then : (u: "a") => void +>u => { let test1: "a" = u } : (u: "a") => void +>u : "a" + + let test1: "a" = u +>test1 : "a" +>u : "a" + } +}) + diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index 800500764a5be..5d2a897899761 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -378,7 +378,7 @@ declare function validateAndClone(obj: { readonly [P in keyof T]?: T[P] }): T >obj : { readonly [P in keyof T]?: T[P] | undefined; } type Foo = { ->Foo : Foo +>Foo : { a?: number | undefined; readonly b: string; } a?: number; >a : number | undefined diff --git a/tests/baselines/reference/jsDeclarationsReactComponents.js b/tests/baselines/reference/jsDeclarationsReactComponents.js index 9c0373e83e739..fb0972b36ed3a 100644 --- a/tests/baselines/reference/jsDeclarationsReactComponents.js +++ b/tests/baselines/reference/jsDeclarationsReactComponents.js @@ -216,7 +216,7 @@ declare const TabbedShowLayout: { }; } & ((props?: { elem: string; -} | undefined) => JSX.Element); +}) => JSX.Element); //// [jsDeclarationsReactComponents4.d.ts] export default TabbedShowLayout; declare function TabbedShowLayout(prop: { diff --git a/tests/baselines/reference/jsDeclarationsWithDefaultAsNamespaceLikeMerge.types b/tests/baselines/reference/jsDeclarationsWithDefaultAsNamespaceLikeMerge.types index 5a083f8e4e6e1..3ac3d722e4fdc 100644 --- a/tests/baselines/reference/jsDeclarationsWithDefaultAsNamespaceLikeMerge.types +++ b/tests/baselines/reference/jsDeclarationsWithDefaultAsNamespaceLikeMerge.types @@ -1,6 +1,6 @@ === /helper.d.ts === type Computed = () => any; ->Computed : Computed +>Computed : () => any interface Mapper { (map: Key[]): { [K in Key]: R }; diff --git a/tests/baselines/reference/jsdocLink3.baseline b/tests/baselines/reference/jsdocLink3.baseline index da1a6fa0cfb26..039d48a13af58 100644 --- a/tests/baselines/reference/jsdocLink3.baseline +++ b/tests/baselines/reference/jsdocLink3.baseline @@ -59,10 +59,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -87,10 +87,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -110,10 +110,10 @@ "text": "C()", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -133,10 +133,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -181,10 +181,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, diff --git a/tests/baselines/reference/jsxCallElaborationCheckNoCrash1.types b/tests/baselines/reference/jsxCallElaborationCheckNoCrash1.types index d3fb0d602549b..e4738eae0a0df 100644 --- a/tests/baselines/reference/jsxCallElaborationCheckNoCrash1.types +++ b/tests/baselines/reference/jsxCallElaborationCheckNoCrash1.types @@ -5,7 +5,7 @@ import * as React from "react"; >React : typeof React type Tags = "span" | "div"; ->Tags : Tags +>Tags : "div" | "span" export const Hoc = ( >Hoc : (TagElement: Tag) => React.SFC diff --git a/tests/baselines/reference/jsxChildrenIndividualErrorElaborations.types b/tests/baselines/reference/jsxChildrenIndividualErrorElaborations.types index 267e3a7027e57..1ebc32a29dc01 100644 --- a/tests/baselines/reference/jsxChildrenIndividualErrorElaborations.types +++ b/tests/baselines/reference/jsxChildrenIndividualErrorElaborations.types @@ -122,7 +122,7 @@ var a = >Blah2 : (props: PropsArr) => JSX.Element type Cb = (x: number) => string; ->Cb : Cb +>Cb : (x: number) => string >x : number interface PropsMixed { diff --git a/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types b/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types index 59292bac60f0d..39de0a51e5a46 100644 --- a/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types +++ b/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types @@ -5,7 +5,7 @@ import * as React from 'react' >React : typeof React type Tab = [string, React.ReactNode] // [tabName, tabContent] ->Tab : Tab +>Tab : [string, React.ReactNode] >React : any interface Props { diff --git a/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.types b/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.types index ec5130e46a03a..9b0f793c10ab1 100644 --- a/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.types +++ b/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.types @@ -126,7 +126,7 @@ export type ValueComponentType = React.ComponentTypeReact : any export type HandlerRendererResult = JSX.Element | null | false; ->HandlerRendererResult : HandlerRendererResult +>HandlerRendererResult : false | JSX.Element | null >JSX : any >null : null >false : false @@ -141,11 +141,11 @@ export type SelectValueHandler = (option: Option) >option : Option export type ArrowRendererHandler = (props: ArrowRendererProps) => HandlerRendererResult; ->ArrowRendererHandler : ArrowRendererHandler +>ArrowRendererHandler : (props: ArrowRendererProps) => HandlerRendererResult >props : ArrowRendererProps export type ClearRendererHandler = () => HandlerRendererResult; ->ClearRendererHandler : ClearRendererHandler +>ClearRendererHandler : () => HandlerRendererResult export type FilterOptionHandler = (option: Option, filter: string) => boolean; >FilterOptionHandler : FilterOptionHandler @@ -159,7 +159,7 @@ export type FilterOptionsHandler = (options: OptionscurrentValues : Options export type InputRendererHandler = (props: { [key: string]: any }) => HandlerRendererResult; ->InputRendererHandler : InputRendererHandler +>InputRendererHandler : (props: { [key: string]: any; }) => HandlerRendererResult >props : { [key: string]: any; } >key : string @@ -168,28 +168,28 @@ export type MenuRendererHandler = (props: MenuRendererPro >props : MenuRendererProps export type OnCloseHandler = () => void; ->OnCloseHandler : OnCloseHandler +>OnCloseHandler : () => void export type OnInputChangeHandler = (inputValue: string) => string; ->OnInputChangeHandler : OnInputChangeHandler +>OnInputChangeHandler : (inputValue: string) => string >inputValue : string export type OnInputKeyDownHandler = React.KeyboardEventHandler; ->OnInputKeyDownHandler : OnInputKeyDownHandler +>OnInputKeyDownHandler : (event: React.KeyboardEvent) => void >React : any export type OnMenuScrollToBottomHandler = () => void; ->OnMenuScrollToBottomHandler : OnMenuScrollToBottomHandler +>OnMenuScrollToBottomHandler : () => void export type OnOpenHandler = () => void; ->OnOpenHandler : OnOpenHandler +>OnOpenHandler : () => void export type OnFocusHandler = React.FocusEventHandler; ->OnFocusHandler : OnFocusHandler +>OnFocusHandler : (event: React.FocusEvent) => void >React : any export type OnBlurHandler = React.FocusEventHandler; ->OnBlurHandler : OnBlurHandler +>OnBlurHandler : (event: React.FocusEvent) => void >React : any export type OptionRendererHandler = (option: Option) => HandlerRendererResult; @@ -216,7 +216,7 @@ export type IsOptionUniqueHandler = (arg: { option: Optio >valueKey : string export type IsValidNewOptionHandler = (arg: { label: string }) => boolean; ->IsValidNewOptionHandler : IsValidNewOptionHandler +>IsValidNewOptionHandler : (arg: { label: string;}) => boolean >arg : { label: string; } >label : string @@ -228,11 +228,11 @@ export type NewOptionCreatorHandler = (arg: { label: stri >valueKey : string export type PromptTextCreatorHandler = (filterText: string) => string; ->PromptTextCreatorHandler : PromptTextCreatorHandler +>PromptTextCreatorHandler : (filterText: string) => string >filterText : string export type ShouldKeyDownEventCreateNewOptionHandler = (arg: { keyCode: number }) => boolean; ->ShouldKeyDownEventCreateNewOptionHandler : ShouldKeyDownEventCreateNewOptionHandler +>ShouldKeyDownEventCreateNewOptionHandler : (arg: { keyCode: number;}) => boolean >arg : { keyCode: number; } >keyCode : number @@ -314,7 +314,7 @@ export interface Option { } export type OptionValues = string | number | boolean; ->OptionValues : OptionValues +>OptionValues : string | number | boolean export interface MenuRendererProps { /** diff --git a/tests/baselines/reference/jsxElementsAsIdentifierNames.js b/tests/baselines/reference/jsxElementsAsIdentifierNames.js new file mode 100644 index 0000000000000..12e0c286b682f --- /dev/null +++ b/tests/baselines/reference/jsxElementsAsIdentifierNames.js @@ -0,0 +1,25 @@ +//// [a.tsx] +declare const React: any; +declare module JSX { + interface IntrinsicElements { + ["package"]: any; + } +} + +function A() { + return +} + +function B() { + return +} + + +//// [a.js] +"use strict"; +function A() { + return React.createElement("package", null); +} +function B() { + return React.createElement("package", null); +} diff --git a/tests/baselines/reference/jsxElementsAsIdentifierNames.symbols b/tests/baselines/reference/jsxElementsAsIdentifierNames.symbols new file mode 100644 index 0000000000000..3b504d515aac9 --- /dev/null +++ b/tests/baselines/reference/jsxElementsAsIdentifierNames.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/a.tsx === +declare const React: any; +>React : Symbol(React, Decl(a.tsx, 0, 13)) + +declare module JSX { +>JSX : Symbol(JSX, Decl(a.tsx, 0, 25)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(a.tsx, 1, 20)) + + ["package"]: any; +>["package"] : Symbol(IntrinsicElements["package"], Decl(a.tsx, 2, 33)) +>"package" : Symbol(IntrinsicElements["package"], Decl(a.tsx, 2, 33)) + } +} + +function A() { +>A : Symbol(A, Decl(a.tsx, 5, 1)) + + return +>package : Symbol(JSX.IntrinsicElements["package"], Decl(a.tsx, 2, 33)) +} + +function B() { +>B : Symbol(B, Decl(a.tsx, 9, 1)) + + return +>package : Symbol(JSX.IntrinsicElements["package"], Decl(a.tsx, 2, 33)) +>package : Symbol(JSX.IntrinsicElements["package"], Decl(a.tsx, 2, 33)) +} + diff --git a/tests/baselines/reference/jsxElementsAsIdentifierNames.types b/tests/baselines/reference/jsxElementsAsIdentifierNames.types new file mode 100644 index 0000000000000..3617a88c1c58e --- /dev/null +++ b/tests/baselines/reference/jsxElementsAsIdentifierNames.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/a.tsx === +declare const React: any; +>React : any + +declare module JSX { + interface IntrinsicElements { + ["package"]: any; +>["package"] : any +>"package" : "package" + } +} + +function A() { +>A : () => any + + return +> : error +>package : any +} + +function B() { +>B : () => any + + return +> : error +>package : any +>package : any +} + diff --git a/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt b/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt index d2acf8482425f..3e15a705edf6c 100644 --- a/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt +++ b/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt @@ -1,8 +1,10 @@ +tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(14,27): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,6): error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Readonly<{ children?: ReactNode; }> & Readonly'. Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'Readonly'. +tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,27): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx (1 errors) ==== +==== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx (3 errors) ==== /// import * as React from 'react'; @@ -17,10 +19,14 @@ tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,6): error TS2322: Typ // Expected no error, got none - good ; + ~~~~~ +!!! error TS2698: Spread types may only be created from object types. // Expected error, but got none - bad! ; ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Readonly<{ children?: ReactNode; }> & Readonly'. !!! error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'Readonly'. + ~~~~~ +!!! error TS2698: Spread types may only be created from object types. }; \ No newline at end of file diff --git a/tests/baselines/reference/jsxFragmentFactoryNoUnusedLocals.types b/tests/baselines/reference/jsxFragmentFactoryNoUnusedLocals.types index a83aca50051ea..a2a388c0bfb7a 100644 --- a/tests/baselines/reference/jsxFragmentFactoryNoUnusedLocals.types +++ b/tests/baselines/reference/jsxFragmentFactoryNoUnusedLocals.types @@ -5,7 +5,7 @@ import { Fragment, createElement } from "react" >createElement : { (type: "input", props?: import("react").InputHTMLAttributes & import("react").ClassAttributes, ...children: import("react").ReactNode[]): import("react").DetailedReactHTMLElement, HTMLInputElement>;

, T extends HTMLElement>(type: keyof import("react").ReactHTML, props?: import("react").ClassAttributes & P, ...children: import("react").ReactNode[]): import("react").DetailedReactHTMLElement;

, T extends SVGElement>(type: keyof import("react").ReactSVG, props?: import("react").ClassAttributes & P, ...children: import("react").ReactNode[]): import("react").ReactSVGElement;

, T extends Element>(type: string, props?: import("react").ClassAttributes & P, ...children: import("react").ReactNode[]): import("react").DOMElement;

(type: import("react").SFC

, props?: import("react").Attributes & P, ...children: import("react").ReactNode[]): import("react").SFCElement

;

(type: import("react").ClassType, import("react").ClassicComponentClass

>, props?: import("react").ClassAttributes> & P, ...children: import("react").ReactNode[]): import("react").CElement>; , C extends import("react").ComponentClass>(type: import("react").ClassType, props?: import("react").ClassAttributes & P, ...children: import("react").ReactNode[]): import("react").CElement;

(type: string | import("react").SFC

| import("react").ComponentClass, props?: import("react").Attributes & P, ...children: import("react").ReactNode[]): import("react").ReactElement

; } type CounterProps = { ->CounterProps : CounterProps +>CounterProps : { count?: number; } count?: number >count : number diff --git a/tests/baselines/reference/jsxLibraryManagedAttributesUnusedGeneric.types b/tests/baselines/reference/jsxLibraryManagedAttributesUnusedGeneric.types index 46f0e28a4b31a..8496f08aa4a52 100644 --- a/tests/baselines/reference/jsxLibraryManagedAttributesUnusedGeneric.types +++ b/tests/baselines/reference/jsxLibraryManagedAttributesUnusedGeneric.types @@ -18,7 +18,7 @@ namespace jsx { export interface IntrinsicAttributes {} export interface IntrinsicClassAttributes {} export type IntrinsicElements = { ->IntrinsicElements : IntrinsicElements +>IntrinsicElements : { div: { className: string;}; } div: { className: string } >div : { className: string; } diff --git a/tests/baselines/reference/jsxLocalNamespaceIndexSignatureNoCrash.types b/tests/baselines/reference/jsxLocalNamespaceIndexSignatureNoCrash.types index f0841d84040c5..3d02da329b8b2 100644 --- a/tests/baselines/reference/jsxLocalNamespaceIndexSignatureNoCrash.types +++ b/tests/baselines/reference/jsxLocalNamespaceIndexSignatureNoCrash.types @@ -17,7 +17,7 @@ export class X { export namespace X { export namespace JSX { export type IntrinsicElements = { ->IntrinsicElements : IntrinsicElements +>IntrinsicElements : { [other: string]: any; } [other: string]: any; >other : string diff --git a/tests/baselines/reference/jsxNamespaceGlobalReexport.types b/tests/baselines/reference/jsxNamespaceGlobalReexport.types index 85fc07e3497e3..655a3a7cab9d9 100644 --- a/tests/baselines/reference/jsxNamespaceGlobalReexport.types +++ b/tests/baselines/reference/jsxNamespaceGlobalReexport.types @@ -51,16 +51,16 @@ export type ComponentType = {}; >ComponentType : ComponentType export type ComponentChild = {}; ->ComponentChild : ComponentChild +>ComponentChild : {} export type ComponentChildren = {}; ->ComponentChildren : ComponentChildren +>ComponentChildren : {} export type VNode = {}; >VNode : VNode export type Attributes = {}; ->Attributes : Attributes +>Attributes : {} export type Component = {}; >Component : Component @@ -90,7 +90,7 @@ import { JSXInternal } from '..'; >JSXInternal : any export function jsx( ->jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; } +>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -110,7 +110,7 @@ export function jsx( ): VNode; export function jsx

( ->jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode; } +>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild;}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

@@ -125,7 +125,7 @@ export function jsx

( ): VNode; export function jsxs( ->jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; } +>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -145,7 +145,7 @@ export function jsxs( ): VNode; export function jsxs

( ->jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode; } +>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild[];}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

@@ -160,7 +160,7 @@ export function jsxs

( ): VNode; export function jsxDEV( ->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; } +>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -180,7 +180,7 @@ export function jsxDEV( ): VNode; export function jsxDEV

( ->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode; } +>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChildren;}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

diff --git a/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types b/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types index 7cc6f7937322c..99dcad4b53f95 100644 --- a/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types +++ b/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types @@ -51,16 +51,16 @@ export type ComponentType = {}; >ComponentType : ComponentType export type ComponentChild = {}; ->ComponentChild : ComponentChild +>ComponentChild : {} export type ComponentChildren = {}; ->ComponentChildren : ComponentChildren +>ComponentChildren : {} export type VNode = {}; >VNode : VNode export type Attributes = {}; ->Attributes : Attributes +>Attributes : {} export type Component = {}; >Component : Component @@ -90,7 +90,7 @@ import { JSXInternal } from '..'; >JSXInternal : any export function jsx( ->jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; } +>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -110,7 +110,7 @@ export function jsx( ): VNode; export function jsx

( ->jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode; } +>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild;}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

@@ -125,7 +125,7 @@ export function jsx

( ): VNode; export function jsxs( ->jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; } +>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -145,7 +145,7 @@ export function jsxs( ): VNode; export function jsxs

( ->jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode; } +>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild[];}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

@@ -160,7 +160,7 @@ export function jsxs

( ): VNode; export function jsxDEV( ->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; } +>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -180,7 +180,7 @@ export function jsxDEV( ): VNode; export function jsxDEV

( ->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode; } +>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChildren;}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

diff --git a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.types b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.types index 8869f10731bb5..71651f958b0a3 100644 --- a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.types +++ b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.types @@ -51,16 +51,16 @@ export type ComponentType = {}; >ComponentType : ComponentType export type ComponentChild = {}; ->ComponentChild : ComponentChild +>ComponentChild : {} export type ComponentChildren = {}; ->ComponentChildren : ComponentChildren +>ComponentChildren : {} export type VNode = {}; >VNode : VNode export type Attributes = {}; ->Attributes : Attributes +>Attributes : {} export type Component = {}; >Component : Component @@ -90,7 +90,7 @@ import { JSXInternal } from '..'; >JSXInternal : any export function jsx( ->jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; } +>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -110,7 +110,7 @@ export function jsx( ): VNode; export function jsx

( ->jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode; } +>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild;}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

@@ -126,7 +126,7 @@ export function jsx

( export function jsxs( ->jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; } +>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -146,7 +146,7 @@ export function jsxs( ): VNode; export function jsxs

( ->jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode; } +>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChild[];}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

@@ -162,7 +162,7 @@ export function jsxs

( export function jsxDEV( ->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string | undefined): VNode;

(type: ComponentType

, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; } +>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string): VNode;

(type: ComponentType

, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; } type: string, >type : string @@ -182,7 +182,7 @@ export function jsxDEV( ): VNode; export function jsxDEV

( ->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode; } +>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode;

(type: ComponentType

, props: Attributes & P & { children?: ComponentChildren;}, key?: string): VNode; } type: ComponentType

, >type : ComponentType

diff --git a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=preserve).types b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=preserve).types index 56cc97e6cea9a..1709e564272f9 100644 --- a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=preserve).types +++ b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=preserve).types @@ -92,7 +92,7 @@ export namespace EmotionJSX { extends ReactJSXIntrinsicClassAttributes {} type IntrinsicElements = { ->IntrinsicElements : IntrinsicElements +>IntrinsicElements : { div: { css?: string | undefined; }; } [K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & { css?: string diff --git a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).types b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).types index 56cc97e6cea9a..1709e564272f9 100644 --- a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).types +++ b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromConfigPickedOverGlobalOne(jsx=react-jsx).types @@ -92,7 +92,7 @@ export namespace EmotionJSX { extends ReactJSXIntrinsicClassAttributes {} type IntrinsicElements = { ->IntrinsicElements : IntrinsicElements +>IntrinsicElements : { div: { css?: string | undefined; }; } [K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & { css?: string diff --git a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.types b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.types index eec34dc7517e7..e51abfb5825aa 100644 --- a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.types +++ b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.types @@ -92,7 +92,7 @@ export namespace EmotionJSX { extends ReactJSXIntrinsicClassAttributes { } type IntrinsicElements = { ->IntrinsicElements : IntrinsicElements +>IntrinsicElements : { div: { css?: string | undefined; }; } [K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & { css?: string diff --git a/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt b/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt index 2eb3df02ad13a..a983e8736b03c 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixInName.errors.txt @@ -19,6 +19,7 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(21,21): error TS1003: Identifi tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,26): error TS1003: Identifier expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,27): error TS1003: Identifier expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,29): error TS1005: '...' expected. +tests/cases/compiler/jsxNamespacePrefixInName.tsx(22,29): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,21): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,22): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,25): error TS1005: ',' expected. @@ -29,7 +30,7 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,42): error TS1109: Expressi tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifier expected. -==== tests/cases/compiler/jsxNamespacePrefixInName.tsx (29 errors) ==== +==== tests/cases/compiler/jsxNamespacePrefixInName.tsx (30 errors) ==== var justElement1 = ; var justElement2 = ; var justElement3 = ; @@ -94,6 +95,8 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifi !!! error TS1003: Identifier expected. ~~~~~~~ !!! error TS1005: '...' expected. + ~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. var beginOfIdent1 = <:a attr={"value"} />; ~ diff --git a/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt b/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt index 890fc67fc262a..bae65da057a4b 100644 --- a/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt +++ b/tests/baselines/reference/jsxNamespacePrefixInNameReact.errors.txt @@ -19,6 +19,7 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(23,21): error TS1003: Ide tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,26): error TS1003: Identifier expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,27): error TS1003: Identifier expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,29): error TS1005: '...' expected. +tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(24,29): error TS2698: Spread types may only be created from object types. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,21): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,22): error TS1109: Expression expected. tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,25): error TS1005: ',' expected. @@ -29,7 +30,7 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(26,42): error TS1109: Exp tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,24): error TS1003: Identifier expected. -==== tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx (29 errors) ==== +==== tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx (30 errors) ==== declare var React: any; var justElement1 = ; @@ -96,6 +97,8 @@ tests/cases/compiler/jsxNamespacePrefixInNameReact.tsx(27,24): error TS1003: Ide !!! error TS1003: Identifier expected. ~~~~~~~ !!! error TS1005: '...' expected. + ~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. var beginOfIdent1 = <:a attr={"value"} />; ~ diff --git a/tests/baselines/reference/jsxParsingError4(strict=true).errors.txt b/tests/baselines/reference/jsxParsingError4(strict=true).errors.txt deleted file mode 100644 index aeac8698a0ae0..0000000000000 --- a/tests/baselines/reference/jsxParsingError4(strict=true).errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -tests/cases/conformance/jsx/a.tsx(13,4): error TS1212: Identifier expected. 'public' is a reserved word in strict mode. -tests/cases/conformance/jsx/a.tsx(13,13): error TS1212: Identifier expected. 'public' is a reserved word in strict mode. - - -==== tests/cases/conformance/jsx/a.tsx (2 errors) ==== - declare const React: any - declare namespace JSX { - interface IntrinsicElements { - [k: string]: any - } - } - - const a = ( - - ); - - const b = ( - - ~~~~~~ -!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode. - ~~~~~~ -!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode. - ); - \ No newline at end of file diff --git a/tests/baselines/reference/jsxParsingError4(strict=true).types b/tests/baselines/reference/jsxParsingError4(strict=true).types index f65d2d679b39c..021360520c02f 100644 --- a/tests/baselines/reference/jsxParsingError4(strict=true).types +++ b/tests/baselines/reference/jsxParsingError4(strict=true).types @@ -10,22 +10,22 @@ declare namespace JSX { } const a = ( ->a : any ->( ) : any +>a : error +>( ) : error -> : any +> : error >public-foo : any >public-foo : any ); const b = ( ->b : any ->( ) : any +>b : error +>( ) : error -> : any +> : error >public : any >public : any diff --git a/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types b/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types index d1823d7997978..493526b9fc7d2 100644 --- a/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types +++ b/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types @@ -3,7 +3,7 @@ import React from "react"; >React : typeof React type InfoProps = ->InfoProps : InfoProps +>InfoProps : { status: "hidden"; } | { status: "visible"; content: string; } | { status: "hidden" } >status : "hidden" diff --git a/tests/baselines/reference/keyRemappingKeyofResult.types b/tests/baselines/reference/keyRemappingKeyofResult.types index 5d8aef034be42..c0a4ea4fefb82 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult.types +++ b/tests/baselines/reference/keyRemappingKeyofResult.types @@ -6,19 +6,19 @@ const sym = Symbol("") >"" : "" type Orig = { [k: string]: any, str: any, [sym]: any } ->Orig : Orig +>Orig : { [k: string]: any; str: any; [sym]: any; } >k : string >str : any >[sym] : any >sym : unique symbol type Okay = Exclude ->Okay : Okay +>Okay : string | number | unique symbol // type Okay = string | number | typeof sym type Remapped = { [K in keyof Orig as {} extends Record ? never : K]: any } ->Remapped : Remapped +>Remapped : { str: any; [sym]: any; } /* type Remapped = { str: any; @@ -27,7 +27,7 @@ type Remapped = { [K in keyof Orig as {} extends Record ? never : K]: an // no string index signature, right? type Oops = Exclude ->Oops : Oops +>Oops : unique symbol | "str" declare let x: Oops; >x : Oops diff --git a/tests/baselines/reference/keyofAndIndexedAccess.errors.txt b/tests/baselines/reference/keyofAndIndexedAccess.errors.txt deleted file mode 100644 index f5c436bbf1dc2..0000000000000 --- a/tests/baselines/reference/keyofAndIndexedAccess.errors.txt +++ /dev/null @@ -1,709 +0,0 @@ -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(316,5): error TS2322: Type 'T' is not assignable to type '{}'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(317,5): error TS2322: Type 'T[keyof T]' is not assignable to type '{}'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{}'. - Type 'T[string]' is not assignable to type '{}'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(318,5): error TS2322: Type 'T[K]' is not assignable to type '{}'. - Type 'T[keyof T]' is not assignable to type '{}'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(323,5): error TS2322: Type 'T' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(324,5): error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. - Type 'T[string]' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(325,5): error TS2322: Type 'T[K]' is not assignable to type '{} | null | undefined'. - Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(611,33): error TS2345: Argument of type 'T[K]' is not assignable to parameter of type '{} | null | undefined'. - Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. - Type 'T[string]' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(619,13): error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. - Type 'T[string]' is not assignable to type '{} | null | undefined'. - - -==== tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts (8 errors) ==== - class Shape { - name: string; - width: number; - height: number; - visible: boolean; - } - - class TaggedShape extends Shape { - tag: string; - } - - class Item { - name: string; - price: number; - } - - class Options { - visible: "yes" | "no"; - } - - type Dictionary = { [x: string]: T }; - type NumericallyIndexed = { [x: number]: T }; - - const enum E { A, B, C } - - type K00 = keyof any; // string - type K01 = keyof string; // "toString" | "charAt" | ... - type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ... - type K03 = keyof boolean; // "valueOf" - type K04 = keyof void; // never - type K05 = keyof undefined; // never - type K06 = keyof null; // never - type K07 = keyof never; // string | number | symbol - type K08 = keyof unknown; // never - - type K10 = keyof Shape; // "name" | "width" | "height" | "visible" - type K11 = keyof Shape[]; // "length" | "toString" | ... - type K12 = keyof Dictionary; // string - type K13 = keyof {}; // never - type K14 = keyof Object; // "constructor" | "toString" | ... - type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ... - type K16 = keyof [string, number]; // "0" | "1" | "length" | "toString" | ... - type K17 = keyof (Shape | Item); // "name" - type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price" - type K19 = keyof NumericallyIndexed // never - - type KeyOf = keyof T; - - type K20 = KeyOf; // "name" | "width" | "height" | "visible" - type K21 = KeyOf>; // string - - type NAME = "name"; - type WIDTH_OR_HEIGHT = "width" | "height"; - - type Q10 = Shape["name"]; // string - type Q11 = Shape["width" | "height"]; // number - type Q12 = Shape["name" | "visible"]; // string | boolean - - type Q20 = Shape[NAME]; // string - type Q21 = Shape[WIDTH_OR_HEIGHT]; // number - - type Q30 = [string, number][0]; // string - type Q31 = [string, number][1]; // number - type Q32 = [string, number][number]; // string | number - type Q33 = [string, number][E.A]; // string - type Q34 = [string, number][E.B]; // number - type Q35 = [string, number]["0"]; // string - type Q36 = [string, number]["1"]; // string - - type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no" - type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no" - - type Q50 = Dictionary["howdy"]; // Shape - type Q51 = Dictionary[123]; // Shape - type Q52 = Dictionary[E.B]; // Shape - - declare let cond: boolean; - - function getProperty(obj: T, key: K) { - return obj[key]; - } - - function setProperty(obj: T, key: K, value: T[K]) { - obj[key] = value; - } - - function f10(shape: Shape) { - let name = getProperty(shape, "name"); // string - let widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number - let nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean - setProperty(shape, "name", "rectangle"); - setProperty(shape, cond ? "width" : "height", 10); - setProperty(shape, cond ? "name" : "visible", true); // Technically not safe - } - - function f11(a: Shape[]) { - let len = getProperty(a, "length"); // number - setProperty(a, "length", len); - } - - function f12(t: [Shape, boolean]) { - let len = getProperty(t, "length"); - let s2 = getProperty(t, "0"); // Shape - let b2 = getProperty(t, "1"); // boolean - } - - function f13(foo: any, bar: any) { - let x = getProperty(foo, "x"); // any - let y = getProperty(foo, "100"); // any - let z = getProperty(foo, bar); // any - } - - class Component { - props: PropType; - getProperty(key: K) { - return this.props[key]; - } - setProperty(key: K, value: PropType[K]) { - this.props[key] = value; - } - } - - function f20(component: Component) { - let name = component.getProperty("name"); // string - let widthOrHeight = component.getProperty(cond ? "width" : "height"); // number - let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean - component.setProperty("name", "rectangle"); - component.setProperty(cond ? "width" : "height", 10) - component.setProperty(cond ? "name" : "visible", true); // Technically not safe - } - - function pluck(array: T[], key: K) { - return array.map(x => x[key]); - } - - function f30(shapes: Shape[]) { - let names = pluck(shapes, "name"); // string[] - let widths = pluck(shapes, "width"); // number[] - let nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[] - } - - function f31(key: K) { - const shape: Shape = { name: "foo", width: 5, height: 10, visible: true }; - return shape[key]; // Shape[K] - } - - function f32(key: K) { - const shape: Shape = { name: "foo", width: 5, height: 10, visible: true }; - return shape[key]; // Shape[K] - } - - function f33(shape: S, key: K) { - let name = getProperty(shape, "name"); - let prop = getProperty(shape, key); - return prop; - } - - function f34(ts: TaggedShape) { - let tag1 = f33(ts, "tag"); - let tag2 = getProperty(ts, "tag"); - } - - class C { - public x: string; - protected y: string; - private z: string; - } - - // Indexed access expressions have always permitted access to private and protected members. - // For consistency we also permit such access in indexed access types. - function f40(c: C) { - type X = C["x"]; - type Y = C["y"]; - type Z = C["z"]; - let x: X = c["x"]; - let y: Y = c["y"]; - let z: Z = c["z"]; - } - - function f50(k: keyof T, s: string) { - const x1 = s as keyof T; - const x2 = k as string; - } - - function f51(k: K, s: string) { - const x1 = s as keyof T; - const x2 = k as string; - } - - function f52(obj: { [x: string]: boolean }, k: Exclude, s: string, n: number) { - const x1 = obj[s]; - const x2 = obj[n]; - const x3 = obj[k]; - } - - function f53>(obj: { [x: string]: boolean }, k: K, s: string, n: number) { - const x1 = obj[s]; - const x2 = obj[n]; - const x3 = obj[k]; - } - - function f54(obj: T, key: keyof T) { - for (let s in obj[key]) { - } - const b = "foo" in obj[key]; - } - - function f55(obj: T, key: K) { - for (let s in obj[key]) { - } - const b = "foo" in obj[key]; - } - - function f60(source: T, target: T) { - for (let k in source) { - target[k] = source[k]; - } - } - - function f70(func: (k1: keyof (T | U), k2: keyof (T & U)) => void) { - func<{ a: any, b: any }, { a: any, c: any }>('a', 'a'); - func<{ a: any, b: any }, { a: any, c: any }>('a', 'b'); - func<{ a: any, b: any }, { a: any, c: any }>('a', 'c'); - } - - function f71(func: (x: T, y: U) => Partial) { - let x = func({ a: 1, b: "hello" }, { c: true }); - x.a; // number | undefined - x.b; // string | undefined - x.c; // boolean | undefined - } - - function f72(func: (x: T, y: U, k: K) => (T & U)[K]) { - let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number - let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string - let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean - } - - function f73(func: (x: T, y: U, k: K) => (T & U)[K]) { - let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number - let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string - let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean - } - - function f74(func: (x: T, y: U, k: K) => (T | U)[K]) { - let a = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a'); // number - let b = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b'); // string | boolean - } - - function f80(obj: T) { - let a1 = obj.a; // { x: any } - let a2 = obj['a']; // { x: any } - let a3 = obj['a'] as T['a']; // T["a"] - let x1 = obj.a.x; // any - let x2 = obj['a']['x']; // any - let x3 = obj['a']['x'] as T['a']['x']; // T["a"]["x"] - } - - function f81(obj: T) { - return obj['a']['x'] as T['a']['x']; - } - - function f82() { - let x1 = f81({ a: { x: "hello" } }); // string - let x2 = f81({ a: { x: 42 } }); // number - } - - function f83(obj: T, key: K) { - return obj[key]['x'] as T[K]['x']; - } - - function f84() { - let x1 = f83({ foo: { x: "hello" } }, "foo"); // string - let x2 = f83({ bar: { x: 42 } }, "bar"); // number - } - - class C1 { - x: number; - get(key: K) { - return this[key]; - } - set(key: K, value: this[K]) { - this[key] = value; - } - foo() { - let x1 = this.x; // number - let x2 = this["x"]; // number - let x3 = this.get("x"); // this["x"] - let x4 = getProperty(this, "x"); // this["x"] - this.x = 42; - this["x"] = 42; - this.set("x", 42); - setProperty(this, "x", 42); - } - } - - type S2 = { - a: string; - b: string; - }; - - function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) { - x1 = x2; - x1 = x3; - x2 = x1; - x2 = x3; - x3 = x1; - x3 = x2; - x1.length; - x2.length; - x3.length; - } - - function f91(x: T, y: T[keyof T], z: T[K]) { - let a: {}; - a = x; - ~ -!!! error TS2322: Type 'T' is not assignable to type '{}'. -!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts:314:14: This type parameter probably needs an `extends object` constraint. - a = y; - ~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{}'. -!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{}'. -!!! error TS2322: Type 'T[string]' is not assignable to type '{}'. - a = z; - ~ -!!! error TS2322: Type 'T[K]' is not assignable to type '{}'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{}'. - } - - function f92(x: T, y: T[keyof T], z: T[K]) { - let a: {} | null | undefined; - a = x; - ~ -!!! error TS2322: Type 'T' is not assignable to type '{} | null | undefined'. -!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts:321:14: This type parameter probably needs an `extends object` constraint. - a = y; - ~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type '{} | null | undefined'. - a = z; - ~ -!!! error TS2322: Type 'T[K]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - } - - // Repros from #12011 - - class Base { - get(prop: K) { - return this[prop]; - } - set(prop: K, value: this[K]) { - this[prop] = value; - } - } - - class Person extends Base { - parts: number; - constructor(parts: number) { - super(); - this.set("parts", parts); - } - getParts() { - return this.get("parts") - } - } - - class OtherPerson { - parts: number; - constructor(parts: number) { - setProperty(this, "parts", parts); - } - getParts() { - return getProperty(this, "parts") - } - } - - // Modified repro from #12544 - - function path(obj: T, key1: K1): T[K1]; - function path(obj: T, key1: K1, key2: K2): T[K1][K2]; - function path(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3]; - function path(obj: any, ...keys: (string | number)[]): any; - function path(obj: any, ...keys: (string | number)[]): any { - let result = obj; - for (let k of keys) { - result = result[k]; - } - return result; - } - - type Thing = { - a: { x: number, y: string }, - b: boolean - }; - - - function f1(thing: Thing) { - let x1 = path(thing, 'a'); // { x: number, y: string } - let x2 = path(thing, 'a', 'y'); // string - let x3 = path(thing, 'b'); // boolean - let x4 = path(thing, ...['a', 'x']); // any - } - - // Repro from comment in #12114 - - const assignTo2 = (object: T, key1: K1, key2: K2) => - (value: T[K1][K2]) => object[key1][key2] = value; - - // Modified repro from #12573 - - declare function one(handler: (t: T) => void): T - var empty = one(() => {}) // inferred as {}, expected - - type Handlers = { [K in keyof T]: (t: T[K]) => void } - declare function on(handlerHash: Handlers): T - var hashOfEmpty1 = on({ test: () => {} }); // {} - var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean } - - // Repro from #12624 - - interface Options1 { - data?: Data - computed?: Computed; - } - - declare class Component1 { - constructor(options: Options1); - get(key: K): (Data & Computed)[K]; - } - - let c1 = new Component1({ - data: { - hello: "" - } - }); - - c1.get("hello"); - - // Repro from #12625 - - interface Options2 { - data?: Data - computed?: Computed; - } - - declare class Component2 { - constructor(options: Options2); - get(key: K): (Data & Computed)[K]; - } - - // Repro from #12641 - - interface R { - p: number; - } - - function f(p: K) { - let a: any; - a[p].add; // any - } - - // Repro from #12651 - - type MethodDescriptor = { - name: string; - args: any[]; - returnValue: any; - } - - declare function dispatchMethod(name: M['name'], args: M['args']): M['returnValue']; - - type SomeMethodDescriptor = { - name: "someMethod"; - args: [string, number]; - returnValue: string[]; - } - - let result = dispatchMethod("someMethod", ["hello", 35]); - - // Repro from #13073 - - type KeyTypes = "a" | "b" - let MyThingy: { [key in KeyTypes]: string[] }; - - function addToMyThingy(key: S) { - MyThingy[key].push("a"); - } - - // Repro from #13102 - - type Handler = { - onChange: (name: keyof T) => void; - }; - - function onChangeGenericFunction(handler: Handler) { - handler.onChange('preset') - } - - // Repro from #13285 - - function updateIds, K extends string>( - obj: T, - idFields: K[], - idMapping: Partial> - ): Record { - for (const idField of idFields) { - const newId: T[K] | undefined = idMapping[obj[idField]]; - if (newId) { - obj[idField] = newId; - } - } - return obj; - } - - // Repro from #13285 - - function updateIds2( - obj: T, - key: K, - stringMap: { [oldId: string]: string } - ) { - var x = obj[key]; - stringMap[x]; // Should be OK. - } - - // Repro from #13514 - - declare function head>(list: T): T[0]; - - // Repro from #13604 - - class A { - props: T & { foo: string }; - } - - class B extends A<{ x: number}> { - f(p: this["props"]) { - p.x; - } - } - - // Repro from #13749 - - class Form { - private childFormFactories: {[K in keyof T]: (v: T[K]) => Form} - - public set(prop: K, value: T[K]) { - this.childFormFactories[prop](value) - } - } - - // Repro from #13787 - - class SampleClass

{ - public props: Readonly

; - constructor(props: P) { - this.props = Object.freeze(props); - } - } - - interface Foo { - foo: string; - } - - declare function merge(obj1: T, obj2: U): T & U; - - class AnotherSampleClass extends SampleClass { - constructor(props: T) { - const foo: Foo = { foo: "bar" }; - super(merge(props, foo)); - } - - public brokenMethod() { - this.props.foo.concat; - } - } - new AnotherSampleClass({}); - - // Positive repro from #17166 - function f3>(t: T, k: K, tk: T[K]): void { - for (let key in t) { - key = k // ok, K ==> keyof T - t[key] = tk; // ok, T[K] ==> T[keyof T] - } - } - - // # 21185 - type Predicates = { - [T in keyof TaggedRecord]: (variant: TaggedRecord[keyof TaggedRecord]) => variant is TaggedRecord[T] - } - - // Repros from #23592 - - type Example = { [K in keyof T]: T[K]["prop"] }; - type Result = Example<{ a: { prop: string }; b: { prop: number } }>; - - type Helper2 = { [K in keyof T]: Extract }; - type Example2 = { [K in keyof Helper2]: Helper2[K]["prop"] }; - type Result2 = Example2<{ 1: { prop: string }; 2: { prop: number } }>; - - // Repro from #23618 - - type DBBoolTable = { [k in K]: 0 | 1 } - enum Flag { - FLAG_1 = "flag_1", - FLAG_2 = "flag_2" - } - - type SimpleDBRecord = { staticField: number } & DBBoolTable - function getFlagsFromSimpleRecord(record: SimpleDBRecord, flags: Flag[]) { - return record[flags[0]]; - } - - type DynamicDBRecord = ({ dynamicField: number } | { dynamicField: string }) & DBBoolTable - function getFlagsFromDynamicRecord(record: DynamicDBRecord, flags: Flag[]) { - return record[flags[0]]; - } - - // Repro from #21368 - - interface I { - foo: string; - } - - declare function take(p: T): void; - - function fn(o: T, k: K) { - take<{} | null | undefined>(o[k]); - ~~~~ -!!! error TS2345: Argument of type 'T[K]' is not assignable to parameter of type '{} | null | undefined'. -!!! error TS2345: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -!!! error TS2345: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. -!!! error TS2345: Type 'T[string]' is not assignable to type '{} | null | undefined'. - take(o[k]); - } - - // Repro from #23133 - - class Unbounded { - foo(x: T[keyof T]) { - let y: {} | undefined | null = x; - ~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type '{} | null | undefined'. - } - } - - // Repro from #23940 - - interface I7 { - x: any; - } - type Foo7 = T; - declare function f7(type: K): Foo7; - - // Repro from #21770 - - type Dict = { [key in T]: number }; - type DictDict = { [key in V]: Dict }; - - function ff1(dd: DictDict, k1: V, k2: T): number { - return dd[k1][k2]; - } - - function ff2(dd: DictDict, k1: V, k2: T): number { - const d: Dict = dd[k1]; - return d[k2]; - } - - // Repro from #26409 - - const cf1 = (t: T, k: K) => - { - const s: string = t[k]; - t.cool; - }; - - const cf2 = (t: T, k: K) => - { - const s: string = t[k]; - t.cool; - }; - \ No newline at end of file diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 0c8af36f1ac79..fc4603b997ff7 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -125,7 +125,7 @@ type NAME = "name"; >NAME : "name" type WIDTH_OR_HEIGHT = "width" | "height"; ->WIDTH_OR_HEIGHT : WIDTH_OR_HEIGHT +>WIDTH_OR_HEIGHT : "width" | "height" type Q10 = Shape["name"]; // string >Q10 : string @@ -134,7 +134,7 @@ type Q11 = Shape["width" | "height"]; // number >Q11 : number type Q12 = Shape["name" | "visible"]; // string | boolean ->Q12 : Q12 +>Q12 : string | boolean type Q20 = Shape[NAME]; // string >Q20 : string @@ -1196,7 +1196,7 @@ class C1 { } type S2 = { ->S2 : S2 +>S2 : { a: string; b: string; } a: string; >a : string @@ -1448,7 +1448,7 @@ function path(obj: any, ...keys: (string | number)[]): any { } type Thing = { ->Thing : Thing +>Thing : { a: { x: number; y: string;}; b: boolean; } a: { x: number, y: string }, >a : { x: number; y: string; } @@ -1646,7 +1646,7 @@ function f(p: K) { // Repro from #12651 type MethodDescriptor = { ->MethodDescriptor : MethodDescriptor +>MethodDescriptor : { name: string; args: any[]; returnValue: any; } name: string; >name : string @@ -1664,7 +1664,7 @@ declare function dispatchMethod(name: M['name'], arg >args : M["args"] type SomeMethodDescriptor = { ->SomeMethodDescriptor : SomeMethodDescriptor +>SomeMethodDescriptor : { name: "someMethod"; args: [string, number]; returnValue: string[]; } name: "someMethod"; >name : "someMethod" @@ -1688,7 +1688,7 @@ let result = dispatchMethod("someMethod", ["hello", 35]); // Repro from #13073 type KeyTypes = "a" | "b" ->KeyTypes : KeyTypes +>KeyTypes : "a" | "b" let MyThingy: { [key in KeyTypes]: string[] }; >MyThingy : { a: string[]; b: string[]; } diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.types b/tests/baselines/reference/keyofAndIndexedAccess2.types index 9fa1ac46783bb..d82644efd53c4 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.types +++ b/tests/baselines/reference/keyofAndIndexedAccess2.types @@ -228,7 +228,7 @@ function f4(a: { [key: string]: number }[K], b: number) { } type Item = { a: string, b: number }; ->Item : Item +>Item : { a: string; b: number; } >a : string >b : number @@ -270,7 +270,7 @@ function f10(obj: T, k1: string, k2: keyof It } type Dict = Record; ->Dict : Dict +>Dict : { [x: string]: number; } function f11(obj: Dict, k1: keyof Dict, k2: K) { >f11 : (obj: Dict, k1: keyof Dict, k2: K) => void diff --git a/tests/baselines/reference/keyofAndIndexedAccessErrors.types b/tests/baselines/reference/keyofAndIndexedAccessErrors.types index 6fb2b69bfad91..ed449ab1e3ec4 100644 --- a/tests/baselines/reference/keyofAndIndexedAccessErrors.types +++ b/tests/baselines/reference/keyofAndIndexedAccessErrors.types @@ -421,7 +421,7 @@ type UndefinedKeys> = { }; type MyType = {a: string, b: string | undefined} ->MyType : MyType +>MyType : { a: string; b: string | undefined; } >a : string >b : string diff --git a/tests/baselines/reference/keyofDoesntContainSymbols.types b/tests/baselines/reference/keyofDoesntContainSymbols.types index 00ccad59caa36..5971064fa36c5 100644 --- a/tests/baselines/reference/keyofDoesntContainSymbols.types +++ b/tests/baselines/reference/keyofDoesntContainSymbols.types @@ -85,6 +85,6 @@ type Values = T[keyof T]; >Values : Values type ValuesOfObj = Values; ->ValuesOfObj : ValuesOfObj +>ValuesOfObj : string | number >obj : { num: number; str: string; 0: 0; [sym]: symbol; } diff --git a/tests/baselines/reference/keyofIntersection.types b/tests/baselines/reference/keyofIntersection.types index f6d636f6a2b4c..b667a08dbe9af 100644 --- a/tests/baselines/reference/keyofIntersection.types +++ b/tests/baselines/reference/keyofIntersection.types @@ -1,10 +1,10 @@ === tests/cases/conformance/types/keyof/keyofIntersection.ts === type A = { a: string }; ->A : A +>A : { a: string; } >a : string type B = { b: string }; ->B : B +>B : { b: string; } >b : string type T01 = keyof (A & B); // "a" | "b" @@ -20,13 +20,13 @@ type T04 = keyof (T & U); // keyof T | keyof U >T04 : keyof T | keyof U type T05 = T02; // "a" | "b" ->T05 : T05 +>T05 : "b" | "a" type T06 = T03; // "a" | "b" ->T06 : T06 +>T06 : "b" | "a" type T07 = T04; // "a" | "b" ->T07 : T07 +>T07 : "b" | "a" // Repros from #22291 @@ -34,7 +34,7 @@ type Example1 = keyof (Record & Reco >Example1 : T | U type Result1 = Example1<'x', 'y'>; // "x" | "y" ->Result1 : Result1 +>Result1 : "x" | "y" type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y" >Result2 : "x" | "y" @@ -55,5 +55,5 @@ type Example5 = keyof (T & U); >Example5 : keyof T | keyof U type Result5 = Example5, Record<'y', any>>; // "x" | "y" ->Result5 : Result5 +>Result5 : "x" | "y" diff --git a/tests/baselines/reference/lambdaParameterWithTupleArgsHasCorrectAssignability.types b/tests/baselines/reference/lambdaParameterWithTupleArgsHasCorrectAssignability.types index 435bdc4c4cf93..539326ab1c791 100644 --- a/tests/baselines/reference/lambdaParameterWithTupleArgsHasCorrectAssignability.types +++ b/tests/baselines/reference/lambdaParameterWithTupleArgsHasCorrectAssignability.types @@ -1,9 +1,9 @@ === tests/cases/compiler/lambdaParameterWithTupleArgsHasCorrectAssignability.ts === type MyTupleItem = {}; ->MyTupleItem : MyTupleItem +>MyTupleItem : {} type MyTuple = [MyTupleItem, ...MyTupleItem[]]; ->MyTuple : MyTuple +>MyTuple : [MyTupleItem, ...MyTupleItem[]] type GenericFunction = (...fromArgs: T) => void; >GenericFunction : GenericFunction diff --git a/tests/baselines/reference/lateBoundConstraintTypeChecksCorrectly.types b/tests/baselines/reference/lateBoundConstraintTypeChecksCorrectly.types index 6cde47ff0dc04..fa806eda9641c 100644 --- a/tests/baselines/reference/lateBoundConstraintTypeChecksCorrectly.types +++ b/tests/baselines/reference/lateBoundConstraintTypeChecksCorrectly.types @@ -6,7 +6,7 @@ declare const barProp: unique symbol; >barProp : unique symbol type BothProps = typeof fooProp | typeof barProp; ->BothProps : BothProps +>BothProps : unique symbol | unique symbol >fooProp : unique symbol >barProp : unique symbol diff --git a/tests/baselines/reference/leaveOptionalParameterAsWritten.js b/tests/baselines/reference/leaveOptionalParameterAsWritten.js new file mode 100644 index 0000000000000..d2a519390a716 --- /dev/null +++ b/tests/baselines/reference/leaveOptionalParameterAsWritten.js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/declarationEmit/leaveOptionalParameterAsWritten.ts] //// + +//// [a.ts] +export interface Foo {} + +//// [b.ts] +import * as a from "./a"; +declare global { + namespace teams { + export namespace calling { + export import Foo = a.Foo; + } + } +} + +//// [c.ts] +type Foo = teams.calling.Foo; +export const bar = (p?: Foo) => {} + + + +//// [a.d.ts] +export interface Foo { +} +//// [b.d.ts] +import * as a from "./a"; +declare global { + namespace teams { + namespace calling { + export import Foo = a.Foo; + } + } +} +//// [c.d.ts] +declare type Foo = teams.calling.Foo; +export declare const bar: (p?: Foo) => void; +export {}; diff --git a/tests/baselines/reference/leaveOptionalParameterAsWritten.symbols b/tests/baselines/reference/leaveOptionalParameterAsWritten.symbols new file mode 100644 index 0000000000000..fbf7d565c51d7 --- /dev/null +++ b/tests/baselines/reference/leaveOptionalParameterAsWritten.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/declarationEmit/a.ts === +export interface Foo {} +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) + +=== tests/cases/conformance/declarationEmit/b.ts === +import * as a from "./a"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + +declare global { +>global : Symbol(global, Decl(b.ts, 0, 25)) + + namespace teams { +>teams : Symbol(teams, Decl(b.ts, 1, 16)) + + export namespace calling { +>calling : Symbol(calling, Decl(b.ts, 2, 19)) + + export import Foo = a.Foo; +>Foo : Symbol(Foo, Decl(b.ts, 3, 30)) +>a : Symbol(a, Decl(b.ts, 0, 6)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) + } + } +} + +=== tests/cases/conformance/declarationEmit/c.ts === +type Foo = teams.calling.Foo; +>Foo : Symbol(Foo, Decl(c.ts, 0, 0)) +>teams : Symbol(teams, Decl(b.ts, 1, 16)) +>calling : Symbol(teams.calling, Decl(b.ts, 2, 19)) +>Foo : Symbol(teams.calling.Foo, Decl(b.ts, 3, 30)) + +export const bar = (p?: Foo) => {} +>bar : Symbol(bar, Decl(c.ts, 1, 12)) +>p : Symbol(p, Decl(c.ts, 1, 20)) +>Foo : Symbol(Foo, Decl(c.ts, 0, 0)) + diff --git a/tests/baselines/reference/leaveOptionalParameterAsWritten.types b/tests/baselines/reference/leaveOptionalParameterAsWritten.types new file mode 100644 index 0000000000000..14632b2b28df4 --- /dev/null +++ b/tests/baselines/reference/leaveOptionalParameterAsWritten.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/declarationEmit/a.ts === +export interface Foo {} +No type information for this code. +No type information for this code.=== tests/cases/conformance/declarationEmit/b.ts === +import * as a from "./a"; +>a : typeof a + +declare global { +>global : typeof global + + namespace teams { +>teams : typeof teams + + export namespace calling { +>calling : typeof calling + + export import Foo = a.Foo; +>Foo : any +>a : typeof a +>Foo : Foo + } + } +} + +=== tests/cases/conformance/declarationEmit/c.ts === +type Foo = teams.calling.Foo; +>Foo : import("tests/cases/conformance/declarationEmit/a").Foo +>teams : any +>calling : any + +export const bar = (p?: Foo) => {} +>bar : (p?: Foo) => void +>(p?: Foo) => {} : (p?: Foo) => void +>p : import("tests/cases/conformance/declarationEmit/a").Foo | undefined + diff --git a/tests/baselines/reference/literalTypeWidening.types b/tests/baselines/reference/literalTypeWidening.types index 6ba61a8072605..f40f9d1229821 100644 --- a/tests/baselines/reference/literalTypeWidening.types +++ b/tests/baselines/reference/literalTypeWidening.types @@ -343,7 +343,7 @@ if (isSuccess(result)) { // Repro from #10898 type TestEvent = "onmouseover" | "onmouseout"; ->TestEvent : TestEvent +>TestEvent : "onmouseover" | "onmouseout" function onMouseOver(): TestEvent { return "onmouseover"; } >onMouseOver : () => TestEvent @@ -398,7 +398,7 @@ export function keys(obj: Record): K[] { } type Obj = { code: LangCode } ->Obj : Obj +>Obj : { code: LangCode; } >code : "fr" | "en" | "es" | "it" | "nl" const langCodeSet = Set('fr', 'en', 'es', 'it', 'nl') diff --git a/tests/baselines/reference/literalTypes1.types b/tests/baselines/reference/literalTypes1.types index f2f25599ae99e..3456663ab0483 100644 --- a/tests/baselines/reference/literalTypes1.types +++ b/tests/baselines/reference/literalTypes1.types @@ -78,7 +78,7 @@ function f2(x: 0 | 1 | 2) { } type Falsy = false | 0 | "" | null | undefined; ->Falsy : Falsy +>Falsy : false | "" | 0 | null | undefined >false : false >null : null diff --git a/tests/baselines/reference/literalTypes2.types b/tests/baselines/reference/literalTypes2.types index 09d4cc3d2189e..6194083b77f74 100644 --- a/tests/baselines/reference/literalTypes2.types +++ b/tests/baselines/reference/literalTypes2.types @@ -756,7 +756,7 @@ function append(a: T[], x: T): T[] { } type Bit = 0 | 1; ->Bit : Bit +>Bit : 0 | 1 let aa = makeArray(0); >aa : Bit[] diff --git a/tests/baselines/reference/localTypeParameterInferencePriority.types b/tests/baselines/reference/localTypeParameterInferencePriority.types index 3297fc40a6f1f..9834da9c9d92a 100644 --- a/tests/baselines/reference/localTypeParameterInferencePriority.types +++ b/tests/baselines/reference/localTypeParameterInferencePriority.types @@ -7,7 +7,7 @@ export type UnrollOnHover = O extends object ? export type Schema = Record; ->Schema : Schema +>Schema : { [x: string]: unknown; } class Table { >Table : Table diff --git a/tests/baselines/reference/mapOnTupleTypes02.types b/tests/baselines/reference/mapOnTupleTypes02.types index 3f443a735cbe3..5e345f3ccf677 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.types +++ b/tests/baselines/reference/mapOnTupleTypes02.types @@ -1,6 +1,6 @@ === tests/cases/compiler/mapOnTupleTypes02.ts === export type Point = [number, number]; ->Point : Point +>Point : [number, number] export function increment(point: Point) { >increment : (point: Point) => number[] diff --git a/tests/baselines/reference/mappedTypeAsClauses.types b/tests/baselines/reference/mappedTypeAsClauses.types index f77042a71e5c1..de951157933a3 100644 --- a/tests/baselines/reference/mappedTypeAsClauses.types +++ b/tests/baselines/reference/mappedTypeAsClauses.types @@ -5,7 +5,7 @@ type Getters = { [P in keyof T & string as `get${Capitalize

}`]: () => T[P] >Getters : Getters type TG1 = Getters<{ foo: string, bar: number, baz: { z: boolean } }>; ->TG1 : TG1 +>TG1 : { getFoo: () => string; getBar: () => number; getBaz: () => { z: boolean; }; } >foo : string >bar : number >baz : { z: boolean; } @@ -22,7 +22,7 @@ type TypeFromDefs> = { [P in T as P['name']]: >TypeFromDefs : TypeFromDefs type TP1 = TypeFromDefs<{ name: 'a', type: string } | { name: 'b', type: number } | { name: 'a', type: boolean }>; ->TP1 : TP1 +>TP1 : { a: string | boolean; b: number; } >name : "a" >type : string >name : "b" @@ -33,10 +33,10 @@ type TP1 = TypeFromDefs<{ name: 'a', type: string } | { name: 'b', type: number // No array or tuple type mapping when 'as N' clause present type TA1 = Getters; ->TA1 : TA1 +>TA1 : { getConcat: () => { (...items: ConcatArray[]): string[]; (...items: (string | ConcatArray)[]): string[]; }; getIndexOf: () => (searchElement: string, fromIndex?: number | undefined) => number; getLastIndexOf: () => (searchElement: string, fromIndex?: number | undefined) => number; getSlice: () => (start?: number | undefined, end?: number | undefined) => string[]; getLength: () => number; getToString: () => () => string; getToLocaleString: () => () => string; getPop: () => () => string | undefined; getPush: () => (...items: string[]) => number; getJoin: () => (separator?: string | undefined) => string; getReverse: () => () => string[]; getShift: () => () => string | undefined; getSort: () => (compareFn?: ((a: string, b: string) => number) | undefined) => string[]; getSplice: () => { (start: number, deleteCount?: number | undefined): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; }; getUnshift: () => (...items: string[]) => number; getEvery: () => { (predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean; }; getSome: () => (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any) => boolean; getForEach: () => (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void; getMap: () => (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]; getFilter: () => { (predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]; }; getReduce: () => { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }; getReduceRight: () => { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }; } type TA2 = Getters<[number, boolean]>; ->TA2 : TA2 +>TA2 : { getConcat: () => { (...items: ConcatArray[]): (number | boolean)[]; (...items: (number | boolean | ConcatArray)[]): (number | boolean)[]; }; getIndexOf: () => (searchElement: number | boolean, fromIndex?: number | undefined) => number; getLastIndexOf: () => (searchElement: number | boolean, fromIndex?: number | undefined) => number; getSlice: () => (start?: number | undefined, end?: number | undefined) => (number | boolean)[]; getLength: () => 2; getToString: () => () => string; getToLocaleString: () => () => string; getPop: () => () => number | boolean | undefined; getPush: () => (...items: (number | boolean)[]) => number; getJoin: () => (separator?: string | undefined) => string; getReverse: () => () => (number | boolean)[]; getShift: () => () => number | boolean | undefined; getSort: () => (compareFn?: ((a: number | boolean, b: number | boolean) => number) | undefined) => [number, boolean]; getSplice: () => { (start: number, deleteCount?: number | undefined): (number | boolean)[]; (start: number, deleteCount: number, ...items: (number | boolean)[]): (number | boolean)[]; }; getUnshift: () => (...items: (number | boolean)[]) => number; getEvery: () => { (predicate: (value: number | boolean, index: number, array: (number | boolean)[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: number | boolean, index: number, array: (number | boolean)[]) => unknown, thisArg?: any): boolean; }; getSome: () => (predicate: (value: number | boolean, index: number, array: (number | boolean)[]) => unknown, thisArg?: any) => boolean; getForEach: () => (callbackfn: (value: number | boolean, index: number, array: (number | boolean)[]) => void, thisArg?: any) => void; getMap: () => (callbackfn: (value: number | boolean, index: number, array: (number | boolean)[]) => U, thisArg?: any) => U[]; getFilter: () => { (predicate: (value: number | boolean, index: number, array: (number | boolean)[]) => value is S, thisArg?: any): S[]; (predicate: (value: number | boolean, index: number, array: (number | boolean)[]) => unknown, thisArg?: any): (number | boolean)[]; }; getReduce: () => { (callbackfn: (previousValue: number | boolean, currentValue: number | boolean, currentIndex: number, array: (number | boolean)[]) => number | boolean): number | boolean; (callbackfn: (previousValue: number | boolean, currentValue: number | boolean, currentIndex: number, array: (number | boolean)[]) => number | boolean, initialValue: number | boolean): number | boolean; (callbackfn: (previousValue: U, currentValue: number | boolean, currentIndex: number, array: (number | boolean)[]) => U, initialValue: U): U; }; getReduceRight: () => { (callbackfn: (previousValue: number | boolean, currentValue: number | boolean, currentIndex: number, array: (number | boolean)[]) => number | boolean): number | boolean; (callbackfn: (previousValue: number | boolean, currentValue: number | boolean, currentIndex: number, array: (number | boolean)[]) => number | boolean, initialValue: number | boolean): number | boolean; (callbackfn: (previousValue: U, currentValue: number | boolean, currentIndex: number, array: (number | boolean)[]) => U, initialValue: U): U; }; get0: () => number; get1: () => boolean; } // Filtering using 'as N' clause @@ -56,7 +56,7 @@ type DoubleProp = { [P in keyof T & string as `${P}1` | `${P}2`]: T[P] } >DoubleProp : DoubleProp type TD1 = DoubleProp<{ a: string, b: number }>; // { a1: string, a2: string, b1: number, b2: number } ->TD1 : TD1 +>TD1 : { a1: string; a2: string; b1: number; b2: number; } >a : string >b : number @@ -91,7 +91,7 @@ type LazyPerson = Lazyify; // Repro from #40833 type Example = {foo: string, bar: number}; ->Example : Example +>Example : { foo: string; bar: number; } >foo : string >bar : number @@ -153,7 +153,7 @@ interface Wheel { } type Primitive = string | number | boolean; ->Primitive : Primitive +>Primitive : string | number | boolean type OnlyPrimitives = { [K in keyof T as T[K] extends Primitive ? K : never]: T[K] }; >OnlyPrimitives : OnlyPrimitives @@ -192,7 +192,7 @@ type GetObjWithIf = { [TP in keyof S as If, TP, never>]: a >GetObjWithIf : GetObjWithIf type Task = { ->Task : Task +>Task : { isDone: boolean; } isDone: boolean; >isDone : boolean @@ -200,7 +200,7 @@ type Task = { }; type Schema = { ->Schema : Schema +>Schema : { root: { title: string; task: Task;}; Task: Task; } root: { >root : { title: string; task: Task; } @@ -252,7 +252,7 @@ f("a"); // Error, should allow only "b" >"a" : "a" type NameMap = { 'a': 'x', 'b': 'y', 'c': 'z' }; ->NameMap : NameMap +>NameMap : { a: 'x'; b: 'y'; c: 'z'; } >'a' : "x" >'b' : "y" >'c' : "z" diff --git a/tests/baselines/reference/mappedTypeConstraints.types b/tests/baselines/reference/mappedTypeConstraints.types index 86d62eb40c56c..86099d594d59f 100644 --- a/tests/baselines/reference/mappedTypeConstraints.types +++ b/tests/baselines/reference/mappedTypeConstraints.types @@ -81,7 +81,7 @@ function f4(obj: RecordTargetProps : TargetProps +>TargetProps : { foo: string; bar: string; } foo: string, >foo : string diff --git a/tests/baselines/reference/mappedTypeConstraints2.errors.txt b/tests/baselines/reference/mappedTypeConstraints2.errors.txt index 5dcfca6d63f5d..7950e9d0f5494 100644 --- a/tests/baselines/reference/mappedTypeConstraints2.errors.txt +++ b/tests/baselines/reference/mappedTypeConstraints2.errors.txt @@ -41,4 +41,26 @@ tests/cases/conformance/types/mapped/mappedTypeConstraints2.ts(25,57): error TS2 ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Foo[`get${T}`]' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo[`get${T}`]'. + + // Repro from #48626 + + interface Bounds { + min: number; + max: number; + } + + type NumericBoundsOf = { + [K in keyof T as T[K] extends number | undefined ? K : never]: Bounds; + } + + function validate(obj: T, bounds: NumericBoundsOf) { + for (const [key, val] of Object.entries(obj)) { + const boundsForKey = bounds[key as keyof NumericBoundsOf]; + if (boundsForKey) { + const { min, max } = boundsForKey; + if (min > val || max < val) return false; + } + } + return true; + } \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeConstraints2.js b/tests/baselines/reference/mappedTypeConstraints2.js index 4c583b3249538..3237f1d8b8107 100644 --- a/tests/baselines/reference/mappedTypeConstraints2.js +++ b/tests/baselines/reference/mappedTypeConstraints2.js @@ -24,20 +24,53 @@ type Foo = { }; const get = (t: T, foo: Foo): T => foo[`get${t}`]; // Type 'Foo[`get${T}`]' is not assignable to type 'T' + +// Repro from #48626 + +interface Bounds { + min: number; + max: number; +} + +type NumericBoundsOf = { + [K in keyof T as T[K] extends number | undefined ? K : never]: Bounds; +} + +function validate(obj: T, bounds: NumericBoundsOf) { + for (const [key, val] of Object.entries(obj)) { + const boundsForKey = bounds[key as keyof NumericBoundsOf]; + if (boundsForKey) { + const { min, max } = boundsForKey; + if (min > val || max < val) return false; + } + } + return true; +} //// [mappedTypeConstraints2.js] "use strict"; function f1(obj, key) { - var x = obj[key]; + const x = obj[key]; } function f2(obj, key) { - var x = obj[key]; // Error + const x = obj[key]; // Error } function f3(obj, key) { - var x = obj[key]; // Error + const x = obj[key]; // Error +} +const get = (t, foo) => foo[`get${t}`]; // Type 'Foo[`get${T}`]' is not assignable to type 'T' +function validate(obj, bounds) { + for (const [key, val] of Object.entries(obj)) { + const boundsForKey = bounds[key]; + if (boundsForKey) { + const { min, max } = boundsForKey; + if (min > val || max < val) + return false; + } + } + return true; } -var get = function (t, foo) { return foo["get".concat(t)]; }; // Type 'Foo[`get${T}`]' is not assignable to type 'T' //// [mappedTypeConstraints2.d.ts] @@ -63,3 +96,11 @@ declare type Foo = { [RemappedT in T as `get${RemappedT}`]: RemappedT; }; declare const get: (t: T, foo: Foo) => T; +interface Bounds { + min: number; + max: number; +} +declare type NumericBoundsOf = { + [K in keyof T as T[K] extends number | undefined ? K : never]: Bounds; +}; +declare function validate(obj: T, bounds: NumericBoundsOf): boolean; diff --git a/tests/baselines/reference/mappedTypeConstraints2.symbols b/tests/baselines/reference/mappedTypeConstraints2.symbols index 9e1727cae64e0..90ee329dada27 100644 --- a/tests/baselines/reference/mappedTypeConstraints2.symbols +++ b/tests/baselines/reference/mappedTypeConstraints2.symbols @@ -104,3 +104,70 @@ const get = (t: T, foo: Foo): T => foo[`get${t}`]; // Type >foo : Symbol(foo, Decl(mappedTypeConstraints2.ts, 24, 36)) >t : Symbol(t, Decl(mappedTypeConstraints2.ts, 24, 31)) +// Repro from #48626 + +interface Bounds { +>Bounds : Symbol(Bounds, Decl(mappedTypeConstraints2.ts, 24, 71)) + + min: number; +>min : Symbol(Bounds.min, Decl(mappedTypeConstraints2.ts, 28, 18)) + + max: number; +>max : Symbol(Bounds.max, Decl(mappedTypeConstraints2.ts, 29, 16)) +} + +type NumericBoundsOf = { +>NumericBoundsOf : Symbol(NumericBoundsOf, Decl(mappedTypeConstraints2.ts, 31, 1)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 33, 21)) + + [K in keyof T as T[K] extends number | undefined ? K : never]: Bounds; +>K : Symbol(K, Decl(mappedTypeConstraints2.ts, 34, 5)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 33, 21)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 33, 21)) +>K : Symbol(K, Decl(mappedTypeConstraints2.ts, 34, 5)) +>K : Symbol(K, Decl(mappedTypeConstraints2.ts, 34, 5)) +>Bounds : Symbol(Bounds, Decl(mappedTypeConstraints2.ts, 24, 71)) +} + +function validate(obj: T, bounds: NumericBoundsOf) { +>validate : Symbol(validate, Decl(mappedTypeConstraints2.ts, 35, 1)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18)) +>obj : Symbol(obj, Decl(mappedTypeConstraints2.ts, 37, 36)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18)) +>bounds : Symbol(bounds, Decl(mappedTypeConstraints2.ts, 37, 43)) +>NumericBoundsOf : Symbol(NumericBoundsOf, Decl(mappedTypeConstraints2.ts, 31, 1)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18)) + + for (const [key, val] of Object.entries(obj)) { +>key : Symbol(key, Decl(mappedTypeConstraints2.ts, 38, 16)) +>val : Symbol(val, Decl(mappedTypeConstraints2.ts, 38, 20)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>obj : Symbol(obj, Decl(mappedTypeConstraints2.ts, 37, 36)) + + const boundsForKey = bounds[key as keyof NumericBoundsOf]; +>boundsForKey : Symbol(boundsForKey, Decl(mappedTypeConstraints2.ts, 39, 13)) +>bounds : Symbol(bounds, Decl(mappedTypeConstraints2.ts, 37, 43)) +>key : Symbol(key, Decl(mappedTypeConstraints2.ts, 38, 16)) +>NumericBoundsOf : Symbol(NumericBoundsOf, Decl(mappedTypeConstraints2.ts, 31, 1)) +>T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18)) + + if (boundsForKey) { +>boundsForKey : Symbol(boundsForKey, Decl(mappedTypeConstraints2.ts, 39, 13)) + + const { min, max } = boundsForKey; +>min : Symbol(min, Decl(mappedTypeConstraints2.ts, 41, 19)) +>max : Symbol(max, Decl(mappedTypeConstraints2.ts, 41, 24)) +>boundsForKey : Symbol(boundsForKey, Decl(mappedTypeConstraints2.ts, 39, 13)) + + if (min > val || max < val) return false; +>min : Symbol(min, Decl(mappedTypeConstraints2.ts, 41, 19)) +>val : Symbol(val, Decl(mappedTypeConstraints2.ts, 38, 20)) +>max : Symbol(max, Decl(mappedTypeConstraints2.ts, 41, 24)) +>val : Symbol(val, Decl(mappedTypeConstraints2.ts, 38, 20)) + } + } + return true; +} + diff --git a/tests/baselines/reference/mappedTypeConstraints2.types b/tests/baselines/reference/mappedTypeConstraints2.types index e1967ee345308..534e02c8518db 100644 --- a/tests/baselines/reference/mappedTypeConstraints2.types +++ b/tests/baselines/reference/mappedTypeConstraints2.types @@ -68,3 +68,63 @@ const get = (t: T, foo: Foo): T => foo[`get${t}`]; // Type >`get${t}` : `get${T}` >t : T +// Repro from #48626 + +interface Bounds { + min: number; +>min : number + + max: number; +>max : number +} + +type NumericBoundsOf = { +>NumericBoundsOf : NumericBoundsOf + + [K in keyof T as T[K] extends number | undefined ? K : never]: Bounds; +} + +function validate(obj: T, bounds: NumericBoundsOf) { +>validate : (obj: T, bounds: NumericBoundsOf) => boolean +>obj : T +>bounds : NumericBoundsOf + + for (const [key, val] of Object.entries(obj)) { +>key : string +>val : any +>Object.entries(obj) : [string, any][] +>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>obj : T + + const boundsForKey = bounds[key as keyof NumericBoundsOf]; +>boundsForKey : NumericBoundsOf[keyof NumericBoundsOf] +>bounds[key as keyof NumericBoundsOf] : NumericBoundsOf[keyof NumericBoundsOf] +>bounds : NumericBoundsOf +>key as keyof NumericBoundsOf : keyof NumericBoundsOf +>key : string + + if (boundsForKey) { +>boundsForKey : NumericBoundsOf[keyof NumericBoundsOf] + + const { min, max } = boundsForKey; +>min : number +>max : number +>boundsForKey : NumericBoundsOf[keyof NumericBoundsOf] + + if (min > val || max < val) return false; +>min > val || max < val : boolean +>min > val : boolean +>min : number +>val : any +>max < val : boolean +>max : number +>val : any +>false : false + } + } + return true; +>true : true +} + diff --git a/tests/baselines/reference/mappedTypeContextualTypesApplied.types b/tests/baselines/reference/mappedTypeContextualTypesApplied.types index fc539785d1b0e..dde424dab5d7b 100644 --- a/tests/baselines/reference/mappedTypeContextualTypesApplied.types +++ b/tests/baselines/reference/mappedTypeContextualTypesApplied.types @@ -1,6 +1,6 @@ === tests/cases/compiler/mappedTypeContextualTypesApplied.ts === type TakeString = (s: string) => any; ->TakeString : TakeString +>TakeString : (s: string) => any >s : string // Various functions accepting an object whose properties are TakeString functions. diff --git a/tests/baselines/reference/mappedTypeErrors.types b/tests/baselines/reference/mappedTypeErrors.types index 3f25f247d2e34..d7d683313aeb7 100644 --- a/tests/baselines/reference/mappedTypeErrors.types +++ b/tests/baselines/reference/mappedTypeErrors.types @@ -29,37 +29,37 @@ interface Point { // Constraint checking type T00 = { [P in P]: string }; // Error ->T00 : T00 +>T00 : { [x: string]: string; } type T01 = { [P in number]: string }; // Error ->T01 : T01 +>T01 : { [x: number]: string; } type T02 = { [P in Date]: number }; // Error ->T02 : T02 +>T02 : {} type T03 = Record; // Error ->T03 : T03 +>T03 : {} type T10 = Pick; ->T10 : T10 +>T10 : { name: string; } type T11 = Pick; // Error ->T11 : T11 +>T11 : { foo: unknown; } type T12 = Pick; // Error ->T12 : T12 +>T12 : { name: string; foo: unknown; } type T13 = Pick; ->T13 : T13 +>T13 : { name: string; } type T14 = Pick; // Error ->T14 : T14 +>T14 : { x: unknown; y: unknown; } type T15 = Pick; ->T15 : T15 +>T15 : {} type T16 = Pick; // Error ->T16 : T16 +>T16 : {} function f1(x: T) { >f1 : (x: T) => void @@ -434,7 +434,7 @@ c.setState({ c: true }); // Error >true : true type T2 = { a?: number, [key: string]: any }; ->T2 : T2 +>T2 : { [key: string]: any; a?: number | undefined; } >a : number | undefined >key : string @@ -469,7 +469,7 @@ type Foo2 = { }; type O = {x: number, y: boolean}; ->O : O +>O : { x: number; y: boolean; } >x : number >y : boolean diff --git a/tests/baselines/reference/mappedTypeErrors2.types b/tests/baselines/reference/mappedTypeErrors2.types index 303cf31061ac9..91b38ae100948 100644 --- a/tests/baselines/reference/mappedTypeErrors2.types +++ b/tests/baselines/reference/mappedTypeErrors2.types @@ -2,7 +2,7 @@ // Repros from #17238 type AB = { ->AB : AB +>AB : { a: 'a'; b: 'a'; } a: 'a' >a : "a" @@ -23,7 +23,7 @@ type R = AB[keyof AB]; // "a" >R : "a" type T3 = { [key in R]: true }; ->T3 : T3 +>T3 : { a: true; } >true : true type T4 = T3[K] // Error diff --git a/tests/baselines/reference/mappedTypeIndexedAccess.types b/tests/baselines/reference/mappedTypeIndexedAccess.types index c145f925bde48..57d446e6dcf1d 100644 --- a/tests/baselines/reference/mappedTypeIndexedAccess.types +++ b/tests/baselines/reference/mappedTypeIndexedAccess.types @@ -18,7 +18,7 @@ type Pair = Pairs[keyof T]; >Pair : Pair type FooBar = { ->FooBar : FooBar +>FooBar : { foo: string; bar: number; } foo: string; >foo : string diff --git a/tests/baselines/reference/mappedTypeInferenceCircularity.types b/tests/baselines/reference/mappedTypeInferenceCircularity.types index 51f1f69f04cf1..591b4fa066052 100644 --- a/tests/baselines/reference/mappedTypeInferenceCircularity.types +++ b/tests/baselines/reference/mappedTypeInferenceCircularity.types @@ -2,7 +2,7 @@ // Repro from #12511 type HTML = { [K in 'div']: Block }; ->HTML : HTML +>HTML : { div: Block; } type Block

= (func: HTML) => {}; >Block : Block

diff --git a/tests/baselines/reference/mappedTypeModifiers.types b/tests/baselines/reference/mappedTypeModifiers.types index 317c3fd052412..dac3cc264120a 100644 --- a/tests/baselines/reference/mappedTypeModifiers.types +++ b/tests/baselines/reference/mappedTypeModifiers.types @@ -1,21 +1,21 @@ === tests/cases/conformance/types/mapped/mappedTypeModifiers.ts === type T = { a: number, b: string }; ->T : T +>T : { a: number; b: string; } >a : number >b : string type TP = { a?: number, b?: string }; ->TP : TP +>TP : { a?: number | undefined; b?: string | undefined; } >a : number | undefined >b : string | undefined type TR = { readonly a: number, readonly b: string }; ->TR : TR +>TR : { readonly a: number; readonly b: string; } >a : number >b : string type TPR = { readonly a?: number, readonly b?: string }; ->TPR : TPR +>TPR : { readonly a?: number | undefined; readonly b?: string | undefined; } >a : number | undefined >b : string | undefined @@ -105,28 +105,28 @@ type Boxified = { [P in keyof T]: { x: T[P] } }; >x : T[P] type B = { a: { x: number }, b: { x: string } }; ->B : B +>B : { a: { x: number;}; b: { x: string;}; } >a : { x: number; } >x : number >b : { x: string; } >x : string type BP = { a?: { x: number }, b?: { x: string } }; ->BP : BP +>BP : { a?: { x: number; } | undefined; b?: { x: string; } | undefined; } >a : { x: number; } | undefined >x : number >b : { x: string; } | undefined >x : string type BR = { readonly a: { x: number }, readonly b: { x: string } }; ->BR : BR +>BR : { readonly a: { x: number;}; readonly b: { x: string;}; } >a : { x: number; } >x : number >b : { x: string; } >x : string type BPR = { readonly a?: { x: number }, readonly b?: { x: string } }; ->BPR : BPR +>BPR : { readonly a?: { x: number; } | undefined; readonly b?: { x: string; } | undefined; } >a : { x: number; } | undefined >x : number >b : { x: string; } | undefined @@ -214,7 +214,7 @@ var b04: Pick; >b04 : BPR type Foo = { prop: number, [x: string]: number }; ->Foo : Foo +>Foo : { [x: string]: number; prop: number; } >prop : number >x : string diff --git a/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types index ae58d3f12ddc3..21db5f8a35b09 100644 --- a/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types +++ b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types @@ -24,7 +24,7 @@ enum AlienAnimalTypes { }; type AnimalTypes = TerrestrialAnimalTypes | AlienAnimalTypes; ->AnimalTypes : AnimalTypes +>AnimalTypes : TerrestrialAnimalTypes | AlienAnimalTypes interface TerrestrialCat { type: TerrestrialAnimalTypes.CAT; @@ -45,10 +45,10 @@ interface AlienCat { } type Cats = TerrestrialCat | AlienCat; ->Cats : Cats +>Cats : TerrestrialCat | AlienCat type CatMap = { ->CatMap : CatMap +>CatMap : { cat: (TerrestrialCat | AlienCat)[]; dog: never[]; } [V in AnimalTypes]: Extract[] >type : V diff --git a/tests/baselines/reference/mappedTypeProperties.types b/tests/baselines/reference/mappedTypeProperties.types index bb40340eacb37..0a75c228660f3 100644 --- a/tests/baselines/reference/mappedTypeProperties.types +++ b/tests/baselines/reference/mappedTypeProperties.types @@ -1,9 +1,9 @@ === tests/cases/conformance/types/mapped/mappedTypeProperties.ts === export type PlaceType = 'openSky' | 'roofed' | 'garage' ->PlaceType : PlaceType +>PlaceType : "openSky" | "roofed" | "garage" type Before = { ->Before : Before +>Before : { model: 'hour' | 'day'; } model: 'hour' | 'day'; >model : "hour" | "day" @@ -16,7 +16,7 @@ type Before = { } type After = { ->After : After +>After : { openSky: void; roofed: void; garage: void; } [placeType in PlaceType]: void; model: 'hour' | 'day' @@ -24,14 +24,14 @@ type After = { } type AfterQuestion = { ->AfterQuestion : AfterQuestion +>AfterQuestion : { openSky?: void; roofed?: void; garage?: void; } [placeType in PlaceType]?: void; model: 'hour' | 'day'; >model : "hour" | "day" } type AfterMethod = { ->AfterMethod : AfterMethod +>AfterMethod : { openSky?: void; roofed?: void; garage?: void; } [placeType in PlaceType]?: void; model(duration: number): 'hour' | 'day'; @@ -40,14 +40,14 @@ type AfterMethod = { } type AfterImplicit = { ->AfterImplicit : AfterImplicit +>AfterImplicit : { openSky: any; roofed: any; garage: any; } [placeType in PlaceType] model: 'hour' | 'day'; >model : "hour" | "day" } type AfterImplicitQ = { ->AfterImplicitQ : AfterImplicitQ +>AfterImplicitQ : { openSky?: any; roofed?: any; garage?: any; } [placeType in PlaceType]? model: 'hour' | 'day' diff --git a/tests/baselines/reference/mappedTypeRelationships.types b/tests/baselines/reference/mappedTypeRelationships.types index f138f86e521f7..7d93248e8f021 100644 --- a/tests/baselines/reference/mappedTypeRelationships.types +++ b/tests/baselines/reference/mappedTypeRelationships.types @@ -322,7 +322,7 @@ function f23(x: T, y: Readonly, k: K) { } type Thing = { a: string, b: string }; ->Thing : Thing +>Thing : { a: string; b: string; } >a : string >b : string @@ -391,14 +391,14 @@ function f41(x: Readonly, y: Readonly) { } type Item = { ->Item : Item +>Item : { name: string; } name: string; >name : string } type ItemMap = { ->ItemMap : ItemMap +>ItemMap : { [x: string]: Item; } [x: string]: Item; >x : string diff --git a/tests/baselines/reference/mappedTypeWithAny.types b/tests/baselines/reference/mappedTypeWithAny.types index 773984fa576d6..983ea1acc7113 100644 --- a/tests/baselines/reference/mappedTypeWithAny.types +++ b/tests/baselines/reference/mappedTypeWithAny.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/mapped/mappedTypeWithAny.ts === type Item = { value: string }; ->Item : Item +>Item : { value: string; } >value : string type ItemMap = { [P in keyof T]: Item }; @@ -24,7 +24,7 @@ declare let x4: ItemMap; // Repro from #19152 type Data = { ->Data : Data +>Data : { value: string; } value: string; >value : string diff --git a/tests/baselines/reference/mappedTypes1.types b/tests/baselines/reference/mappedTypes1.types index 9c33653214b54..4dac0fa8c47b0 100644 --- a/tests/baselines/reference/mappedTypes1.types +++ b/tests/baselines/reference/mappedTypes1.types @@ -1,80 +1,80 @@ === tests/cases/conformance/types/mapped/mappedTypes1.ts === type Item = { a: string, b: number, c: boolean }; ->Item : Item +>Item : { a: string; b: number; c: boolean; } >a : string >b : number >c : boolean type T00 = { [P in "x" | "y"]: number }; ->T00 : T00 +>T00 : { x: number; y: number; } type T01 = { [P in "x" | "y"]: P }; ->T01 : T01 +>T01 : { x: "x"; y: "y"; } type T02 = { [P in "a" | "b"]: Item[P]; } ->T02 : T02 +>T02 : { a: string; b: number; } type T03 = { [P in keyof Item]: Date }; ->T03 : T03 +>T03 : { a: Date; b: Date; c: Date; } type T10 = { [P in keyof Item]: Item[P] }; ->T10 : T10 +>T10 : { a: string; b: number; c: boolean; } type T11 = { [P in keyof Item]?: Item[P] }; ->T11 : T11 +>T11 : { a?: string | undefined; b?: number | undefined; c?: boolean | undefined; } type T12 = { readonly [P in keyof Item]: Item[P] }; ->T12 : T12 +>T12 : { readonly a: string; readonly b: number; readonly c: boolean; } type T13 = { readonly [P in keyof Item]?: Item[P] }; ->T13 : T13 +>T13 : { readonly a?: string | undefined; readonly b?: number | undefined; readonly c?: boolean | undefined; } type T20 = { [P in keyof Item]: Item[P] | null }; ->T20 : T20 +>T20 : { a: string | null; b: number | null; c: boolean | null; } >null : null type T21 = { [P in keyof Item]: Array }; ->T21 : T21 +>T21 : { a: string[]; b: number[]; c: boolean[]; } type T30 = { [P in keyof any]: void }; ->T30 : T30 +>T30 : { [x: string]: void; } type T31 = { [P in keyof string]: void }; ->T31 : T31 +>T31 : { [x: number]: void; toString: void; charAt: void; charCodeAt: void; concat: void; indexOf: void; lastIndexOf: void; localeCompare: void; match: void; replace: void; search: void; slice: void; split: void; substring: void; toLowerCase: void; toLocaleLowerCase: void; toUpperCase: void; toLocaleUpperCase: void; trim: void; readonly length: void; substr: void; valueOf: void; } type T32 = { [P in keyof number]: void }; ->T32 : T32 +>T32 : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; } type T33 = { [P in keyof boolean]: void }; ->T33 : T33 +>T33 : { valueOf: void; } type T34 = { [P in keyof undefined]: void }; ->T34 : T34 +>T34 : {} type T35 = { [P in keyof null]: void }; ->T35 : T35 +>T35 : {} >null : null type T36 = { [P in keyof void]: void }; ->T36 : T36 +>T36 : {} type T37 = { [P in keyof symbol]: void }; ->T37 : T37 +>T37 : { toString: void; valueOf: void; } type T38 = { [P in keyof never]: void }; ->T38 : T38 +>T38 : {} type T40 = { [P in string]: void }; ->T40 : T40 +>T40 : { [x: string]: void; } type T43 = { [P in "a" | "b"]: void }; ->T43 : T43 +>T43 : { a: void; b: void; } type T44 = { [P in "a" | "b" | "0" | "1"]: void }; ->T44 : T44 +>T44 : { a: void; b: void; 0: void; 1: void; } type T47 = { [P in string | "a" | "b" | "0" | "1"]: void }; ->T47 : T47 +>T47 : { [x: string]: void; } declare function f1(): { [P in keyof T1]: void }; >f1 : () => { [P in keyof T1]: void; } diff --git a/tests/baselines/reference/mappedTypes4.types b/tests/baselines/reference/mappedTypes4.types index 7f7c36fc85c55..85e714a4f0043 100644 --- a/tests/baselines/reference/mappedTypes4.types +++ b/tests/baselines/reference/mappedTypes4.types @@ -49,15 +49,15 @@ function boxify(obj: T): Boxified { } type A = { a: string }; ->A : A +>A : { a: string; } >a : string type B = { b: string }; ->B : B +>B : { b: string; } >b : string type C = { c: string }; ->C : C +>C : { c: string; } >c : string function f1(x: A | B | C | undefined) { @@ -71,25 +71,25 @@ function f1(x: A | B | C | undefined) { } type T00 = Partial; ->T00 : T00 +>T00 : Partial | Partial | Partial type T01 = Readonly; ->T01 : T01 +>T01 : Readonly | Readonly | Readonly | null | undefined >null : null type T02 = Boxified ->T02 : T02 +>T02 : string | Boxified | Boxified | Box[] type T03 = Readonly; ->T03 : T03 +>T03 : string | number | boolean | void | null | undefined >null : null type T04 = Boxified; ->T04 : T04 +>T04 : string | number | boolean | void | null | undefined >null : null type T05 = Partial<"hello" | "world" | 42>; ->T05 : T05 +>T05 : "hello" | "world" | 42 type BoxifiedWithSentinel = { >BoxifiedWithSentinel : BoxifiedWithSentinel @@ -98,11 +98,11 @@ type BoxifiedWithSentinel = { } type T10 = BoxifiedWithSentinel; ->T10 : T10 +>T10 : BoxifiedWithSentinel | BoxifiedWithSentinel | BoxifiedWithSentinel >null : null type T11 = BoxifiedWithSentinel; ->T11 : T11 +>T11 : BoxifiedWithSentinel | BoxifiedWithSentinel | BoxifiedWithSentinel type T12 = BoxifiedWithSentinel; >T12 : string @@ -114,7 +114,7 @@ type DeepReadonly = { }; type Foo = { ->Foo : Foo +>Foo : { x: number; y: { a: string; b: number;}; z: boolean; } x: number; >x : number @@ -130,7 +130,7 @@ type Foo = { }; type DeepReadonlyFoo = { ->DeepReadonlyFoo : DeepReadonlyFoo +>DeepReadonlyFoo : { readonly x: number; readonly y: { readonly a: string; readonly b: number;}; readonly z: boolean; } readonly x: number; >x : number @@ -154,7 +154,7 @@ var x1: DeepReadonlyFoo; // Repro from #13232 type Z = { a: number }; ->Z : Z +>Z : { a: number; } >a : number type Clone = { diff --git a/tests/baselines/reference/mappedTypes5.types b/tests/baselines/reference/mappedTypes5.types index 587f0b0e3ddd3..ba6b43f7a44bf 100644 --- a/tests/baselines/reference/mappedTypes5.types +++ b/tests/baselines/reference/mappedTypes5.types @@ -74,7 +74,7 @@ function f(p: Partial, r: Readonly, pr: Partial>, rp: Reado // Repro from #17682 type State = { ->State : State +>State : { [key: string]: string | number | boolean | null; } [key: string]: string | boolean | number | null; >key : string @@ -137,12 +137,12 @@ function doit() { } type State2 = { foo: number, bar: string }; ->State2 : State2 +>State2 : { foo: number; bar: string; } >foo : number >bar : string type Args3 = { ->Args3 : Args3 +>Args3 : { readonly previous: Readonly>; readonly current: Readonly>; } readonly previous: Readonly>; >previous : Readonly> @@ -153,7 +153,7 @@ type Args3 = { }; type Args4 = { ->Args4 : Args4 +>Args4 : { readonly previous: Partial>; readonly current: Partial>; } readonly previous: Partial>; >previous : Partial> diff --git a/tests/baselines/reference/mappedTypes6.types b/tests/baselines/reference/mappedTypes6.types index 9c8d5e8a3d7fa..871f6867612bc 100644 --- a/tests/baselines/reference/mappedTypes6.types +++ b/tests/baselines/reference/mappedTypes6.types @@ -278,7 +278,7 @@ function f10(x: Readonly, y: T, z: Readwrite) { } type Foo = { ->Foo : Foo +>Foo : { a: number; b: number | undefined; c?: number | undefined; d?: number | undefined; } a: number; >a : number @@ -420,7 +420,7 @@ x2 = { a: 1, b: 1, c: 1, d: 1 }; >1 : 1 type Bar = { ->Bar : Bar +>Bar : { a: number; readonly b: number; } a: number; >a : number diff --git a/tests/baselines/reference/mappedTypesAndObjects.errors.txt b/tests/baselines/reference/mappedTypesAndObjects.errors.txt deleted file mode 100644 index c32fc58b370e7..0000000000000 --- a/tests/baselines/reference/mappedTypesAndObjects.errors.txt +++ /dev/null @@ -1,54 +0,0 @@ -tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts(25,11): error TS2430: Interface 'E1' incorrectly extends interface 'Base'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type '{ [key: string]: any; }'. - - -==== tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts (1 errors) ==== - function f1(x: Partial, y: Readonly) { - let obj: {}; - obj = x; - obj = y; - } - - function f2(x: Partial, y: Readonly) { - let obj: { [x: string]: any }; - obj = x; - obj = y; - } - - function f3(x: Partial) { - x = {}; - } - - // Repro from #12900 - - interface Base { - foo: { [key: string]: any }; - bar: any; - baz: any; - } - - interface E1 extends Base { - ~~ -!!! error TS2430: Interface 'E1' incorrectly extends interface 'Base'. -!!! error TS2430: Types of property 'foo' are incompatible. -!!! error TS2430: Type 'T' is not assignable to type '{ [key: string]: any; }'. -!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts:25:14: This type parameter probably needs an `extends object` constraint. - foo: T; - } - - interface Something { name: string, value: string }; - interface E2 extends Base { - foo: Partial; // or other mapped type - } - - interface E3 extends Base { - foo: Partial; // or other mapped type - } - - // Repro from #13747 - - class Form { - private values: {[P in keyof T]?: T[P]} = {} - } - \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypesArraysTuples.types b/tests/baselines/reference/mappedTypesArraysTuples.types index 082890b009713..dbd83076d3b2a 100644 --- a/tests/baselines/reference/mappedTypesArraysTuples.types +++ b/tests/baselines/reference/mappedTypesArraysTuples.types @@ -58,15 +58,15 @@ type T31 = Partial>; >T31 : (Box | undefined)[] type A = { a: string }; ->A : A +>A : { a: string; } >a : string type B = { b: string }; ->B : B +>B : { b: string; } >b : string type T40 = Boxified | [A, B] | string | string[]>; ->T40 : T40 +>T40 : string | Box[] | Boxified | readonly Box[] | [Box, Box] | Box[] type ReadWrite = { -readonly [P in keyof T] : T[P] }; >ReadWrite : ReadWrite diff --git a/tests/baselines/reference/misspelledNewMetaProperty.symbols b/tests/baselines/reference/misspelledNewMetaProperty.symbols index 55ab6fe7a6768..d14d7eadeff2f 100644 --- a/tests/baselines/reference/misspelledNewMetaProperty.symbols +++ b/tests/baselines/reference/misspelledNewMetaProperty.symbols @@ -2,5 +2,4 @@ function foo(){new.targ} >foo : Symbol(foo, Decl(misspelledNewMetaProperty.ts, 0, 0)) >new.targ : Symbol(foo, Decl(misspelledNewMetaProperty.ts, 0, 0)) ->targ : Symbol(foo, Decl(misspelledNewMetaProperty.ts, 0, 0)) diff --git a/tests/baselines/reference/mixinAccessModifiers.types b/tests/baselines/reference/mixinAccessModifiers.types index 9b4cb432ab2e2..c104bfa23570b 100644 --- a/tests/baselines/reference/mixinAccessModifiers.types +++ b/tests/baselines/reference/mixinAccessModifiers.types @@ -1,6 +1,6 @@ === tests/cases/conformance/classes/mixinAccessModifiers.ts === type Constructable = new (...args: any[]) => object; ->Constructable : Constructable +>Constructable : new (...args: any[]) => object >args : any[] class Private { diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node12).js b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).js similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node12).js rename to tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).js diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node12).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).symbols similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node12).symbols rename to tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).symbols diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node12).types b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).types similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node12).types rename to tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).types diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).errors.txt b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).errors.txt similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).errors.txt rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).errors.txt diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).js b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).js similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).js rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).js diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).symbols similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).symbols rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).symbols diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).types b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).types similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node).types rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).types diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node12).js b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).js similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node12).js rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).js diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node12).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).symbols similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node12).symbols rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).symbols diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node12).types b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).types similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=node12).types rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).types diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=nodenext).js b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).js similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=nodenext).js rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).js diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=nodenext).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).symbols similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=nodenext).symbols rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).symbols diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=nodenext).types b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).types similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=node12,moduleresolution=nodenext).types rename to tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).types diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node12).js b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).js similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node12).js rename to tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).js diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node12).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).symbols similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node12).symbols rename to tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).symbols diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node12).types b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).types similarity index 100% rename from tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node12).types rename to tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).types diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt index 5f3cbbc121cfb..30a2033c2b1fb 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt @@ -1,5 +1,5 @@ -/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.mjs'? -/src/bar.mts(3,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'? +/src/bar.mts(3,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== /src/foo.mts (0 errors) ==== @@ -11,8 +11,8 @@ // Extensionless relative path ES import in an ES module import { foo } from "./foo"; // should error, suggest adding ".mjs" ~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'? import { baz } from "./baz"; // should error, ask for extension, no extension suggestion ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt index 0c753a1029900..356bbda92dd16 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt @@ -1,4 +1,4 @@ -/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.jsx'? +/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'? ==== /src/foo.tsx (0 errors) ==== @@ -10,5 +10,5 @@ // Extensionless relative path ES import in an ES module import { foo } from "./foo"; // should error, suggest adding ".jsx" ~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.jsx'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'? \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt index afd24269d69bc..917ae242e7afd 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt @@ -1,4 +1,4 @@ -/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.js'? +/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'? ==== /src/foo.tsx (0 errors) ==== @@ -10,5 +10,5 @@ // Extensionless relative path ES import in an ES module import { foo } from "./foo"; // should error, suggest adding ".js" ~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.js'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'? \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt index b4b0a89ae974f..2660f052ec9e7 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt @@ -1,8 +1,8 @@ -/src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +/src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== /src/buzz.mts (1 errors) ==== // Extensionless relative path dynamic import in an ES module import("./foo").then(x => x); // should error, ask for extension ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt index c990522c6c707..b857c4d7fbc86 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt @@ -1,8 +1,8 @@ -/src/bar.cts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +/src/bar.cts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== /src/bar.cts (1 errors) ==== // Extensionless relative path dynamic import in a cjs module import("./foo").then(x => x); // should error, ask for extension ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/namedTupleMembers.types b/tests/baselines/reference/namedTupleMembers.types index 100eeb0679e85..224c928c5f281 100644 --- a/tests/baselines/reference/namedTupleMembers.types +++ b/tests/baselines/reference/namedTupleMembers.types @@ -1,9 +1,9 @@ === tests/cases/conformance/types/tuple/named/namedTupleMembers.ts === export type Segment = [length: number, count: number]; ->Segment : Segment +>Segment : [length: number, count: number] export type SegmentAnnotated = [ ->SegmentAnnotated : SegmentAnnotated +>SegmentAnnotated : [length: number, count: number] /** * Size of message buffer segment handles @@ -88,7 +88,7 @@ d = c; >c : [number, number] export type WithOptAndRest = [first: number, second?: number, ...rest: string[]]; ->WithOptAndRest : WithOptAndRest +>WithOptAndRest : [first: number, second?: number, ...rest: string[]] export type Func = (...x: T) => void; >Func : Func @@ -112,7 +112,7 @@ export function useState(initial: T): [value: T, setter: (T) => void] { export type Iter = Func<[step: number, iterations: number]>; ->Iter : Iter +>Iter : (step: number, iterations: number) => void export function readSegment([length, count]: [number, number]) {} >readSegment : ([length, count]: [number, number]) => void @@ -128,10 +128,10 @@ export const val = null as any as Parameters[0]; >readSegment : ([length, count]: [number, number]) => void export type RecursiveTupleA = [initial: string, next: RecursiveTupleA]; ->RecursiveTupleA : RecursiveTupleA +>RecursiveTupleA : [initial: string, next: RecursiveTupleA] export type RecursiveTupleB = [first: string, ptr: RecursiveTupleB]; ->RecursiveTupleB : RecursiveTupleB +>RecursiveTupleB : [first: string, ptr: RecursiveTupleB] declare var q: RecursiveTupleA; >q : RecursiveTupleA @@ -150,10 +150,10 @@ r = q; >q : RecursiveTupleA export type RecusiveRest = [first: string, ...rest: RecusiveRest[]]; ->RecusiveRest : RecusiveRest +>RecusiveRest : [first: string, ...rest: RecusiveRest[]] export type RecusiveRest2 = [string, ...RecusiveRest2[]]; ->RecusiveRest2 : RecusiveRest2 +>RecusiveRest2 : [string, ...RecusiveRest2[]] declare var x: RecusiveRest; >x : RecusiveRest diff --git a/tests/baselines/reference/namedTupleMembersErrors.types b/tests/baselines/reference/namedTupleMembersErrors.types index 0ae16d3b68353..a191b57a718dc 100644 --- a/tests/baselines/reference/namedTupleMembersErrors.types +++ b/tests/baselines/reference/namedTupleMembersErrors.types @@ -1,9 +1,9 @@ === tests/cases/conformance/types/tuple/named/namedTupleMembersErrors.ts === export type Segment1 = [length: number, number]; // partially named, disallowed ->Segment1 : Segment1 +>Segment1 : [number, number] export type Segment2 = [number, size: number]; // partially named, disallowed ->Segment2 : Segment2 +>Segment2 : [number, number] export type List = [item: any, ...any]; // partially named, disallowed >List : [any, ...any[]] @@ -12,22 +12,22 @@ export type List2 = [any, ...remainder: any]; // partially named, disallowed >List2 : [any, ...any[]] export type Pair = [item: any, any?]; // partially named, disallowed ->Pair : Pair +>Pair : [any, any?] export type Pair2 = [any, last?: any]; // partially named, disallowed ->Pair2 : Pair2 +>Pair2 : [any, any?] export type Opt = [element: string?]; // question mark on element disallowed ->Opt : Opt +>Opt : [element: string] export type Trailing = [first: string, rest: ...string[]]; // dots on element disallowed ->Trailing : Trailing +>Trailing : [first: string, rest: string] export type OptTrailing = [first: string, rest: ...string[]?]; // dots+question on element disallowed ->OptTrailing : OptTrailing +>OptTrailing : [first: string, rest: string[]] export type OptRest = [first: string, ...rest?: string[]]; // rest+optional disallowed ->OptRest : OptRest +>OptRest : [first: string, rest?: string] export type NonArrayRest = [first: string, ...rest: number]; // non-arraylike rest, disallowed >NonArrayRest : [first: string, ...rest: any[]] diff --git a/tests/baselines/reference/namespaceDisambiguationInUnion.types b/tests/baselines/reference/namespaceDisambiguationInUnion.types index a7852beebd22f..0c0761699ad12 100644 --- a/tests/baselines/reference/namespaceDisambiguationInUnion.types +++ b/tests/baselines/reference/namespaceDisambiguationInUnion.types @@ -1,13 +1,13 @@ === tests/cases/compiler/namespaceDisambiguationInUnion.ts === namespace Foo { export type Yep = { type: "foo.yep" }; ->Yep : Yep +>Yep : { type: "foo.yep"; } >type : "foo.yep" } namespace Bar { export type Yep = { type: "bar.yep" }; ->Yep : Yep +>Yep : { type: "bar.yep"; } >type : "bar.yep" } diff --git a/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types index 06f5ecaca0fd5..e470490a32f99 100644 --- a/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types +++ b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types @@ -1,7 +1,7 @@ === tests/cases/compiler/file1.ts === export namespace Library { export type Bar = { a: number }; ->Bar : Bar +>Bar : { a: number; } >a : number } var x: Library.Bar; // should work diff --git a/tests/baselines/reference/narrowTypeByInstanceof.types b/tests/baselines/reference/narrowTypeByInstanceof.types index 65b706eea76cd..57427f90fa210 100644 --- a/tests/baselines/reference/narrowTypeByInstanceof.types +++ b/tests/baselines/reference/narrowTypeByInstanceof.types @@ -22,7 +22,7 @@ } type FileMatchOrMatch = FileMatch | Match; ->FileMatchOrMatch : FileMatchOrMatch +>FileMatchOrMatch : Match | FileMatch let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; diff --git a/tests/baselines/reference/narrowingByDiscriminantInLoop.types b/tests/baselines/reference/narrowingByDiscriminantInLoop.types index 34c68000850eb..db7a2a59e2532 100644 --- a/tests/baselines/reference/narrowingByDiscriminantInLoop.types +++ b/tests/baselines/reference/narrowingByDiscriminantInLoop.types @@ -2,7 +2,7 @@ // Repro from #9977 type IDLMemberTypes = OperationMemberType | ConstantMemberType; ->IDLMemberTypes : IDLMemberTypes +>IDLMemberTypes : OperationMemberType | ConstantMemberType interface IDLTypeDescription { origin: string; diff --git a/tests/baselines/reference/narrowingByTypeofInSwitch.types b/tests/baselines/reference/narrowingByTypeofInSwitch.types index 2b028aad6bd16..96897cd71de20 100644 --- a/tests/baselines/reference/narrowingByTypeofInSwitch.types +++ b/tests/baselines/reference/narrowingByTypeofInSwitch.types @@ -97,7 +97,7 @@ function assertBooleanOrObject(x: boolean | object) { } type Basic = number | boolean | string | symbol | object | Function | undefined; ->Basic : Basic +>Basic : string | number | boolean | symbol | object | Function | undefined function testUnion(x: Basic) { >testUnion : (x: Basic) => void @@ -431,11 +431,11 @@ function testExtendsImplicitDefault(x: T) { } type L = (x: number) => string; ->L : L +>L : (x: number) => string >x : number type R = { x: string, y: number } ->R : R +>R : { x: string; y: number; } >x : string >y : number diff --git a/tests/baselines/reference/narrowingDestructuring.types b/tests/baselines/reference/narrowingDestructuring.types index a942e163da860..24ff38a297d56 100644 --- a/tests/baselines/reference/narrowingDestructuring.types +++ b/tests/baselines/reference/narrowingDestructuring.types @@ -1,6 +1,6 @@ === tests/cases/compiler/narrowingDestructuring.ts === type X = { kind: "a", a: string } | { kind: "b", b: string } ->X : X +>X : { kind: "a"; a: string; } | { kind: "b"; b: string; } >kind : "a" >a : string >kind : "b" @@ -39,7 +39,7 @@ function func(value: T) { } type Z = { kind: "f", f: { a: number, b: string, c: number } } ->Z : Z +>Z : { kind: "f"; f: { a: number; b: string; c: number;}; } | { kind: "g"; g: { a: string; b: number; c: string;}; } >kind : "f" >f : { a: number; b: string; c: number; } >a : number diff --git a/tests/baselines/reference/narrowingIntersection.types b/tests/baselines/reference/narrowingIntersection.types index ba44c888c803b..c6f229e39698d 100644 --- a/tests/baselines/reference/narrowingIntersection.types +++ b/tests/baselines/reference/narrowingIntersection.types @@ -1,12 +1,12 @@ === tests/cases/compiler/narrowingIntersection.ts === // Somehow this being an intersection matters. type FooAndBaz = { foo: unknown } & { baz: unknown }; ->FooAndBaz : FooAndBaz +>FooAndBaz : { foo: unknown; } & { baz: unknown; } >foo : unknown >baz : unknown type Disjoint = ->Disjoint : Disjoint +>Disjoint : { readonly value: string; readonly err?: never; } | { readonly value?: never; readonly err: FooAndBaz; } | { readonly value: string; readonly err?: never; } >value : string @@ -38,7 +38,7 @@ function test1(result: Disjoint): string { } type TrivialIntersection = { a: 1 } & { a: 1 }; ->TrivialIntersection : TrivialIntersection +>TrivialIntersection : { a: 1; } & { a: 1; } >a : 1 >a : 1 diff --git a/tests/baselines/reference/narrowingOfQualifiedNames.types b/tests/baselines/reference/narrowingOfQualifiedNames.types index 59349ce8e18eb..d95620a6dda35 100644 --- a/tests/baselines/reference/narrowingOfQualifiedNames.types +++ b/tests/baselines/reference/narrowingOfQualifiedNames.types @@ -261,19 +261,19 @@ function init2(foo: DeepOptional) { // Repro from #48289 type Fish = { type: 'fish', hasFins: true } ->Fish : Fish +>Fish : { type: 'fish'; hasFins: true; } >type : "fish" >hasFins : true >true : true type Dog = { type: 'dog', saysWoof: true } ->Dog : Dog +>Dog : { type: 'dog'; saysWoof: true; } >type : "dog" >saysWoof : true >true : true type Pet = Fish | Dog; ->Pet : Pet +>Pet : Fish | Dog function handleDogBroken(pet: PetType) { >handleDogBroken : (pet: PetType) => void diff --git a/tests/baselines/reference/narrowingTypeofFunction.types b/tests/baselines/reference/narrowingTypeofFunction.types index 9342585ddd54e..6290fe95c3782 100644 --- a/tests/baselines/reference/narrowingTypeofFunction.types +++ b/tests/baselines/reference/narrowingTypeofFunction.types @@ -1,6 +1,6 @@ === tests/cases/compiler/narrowingTypeofFunction.ts === type Meta = { foo: string } ->Meta : Meta +>Meta : { foo: string; } >foo : string interface F { (): string } diff --git a/tests/baselines/reference/nearbyIdenticalGenericLambdasAssignable.types b/tests/baselines/reference/nearbyIdenticalGenericLambdasAssignable.types index 74b907ee4adad..55fa9e45cdf51 100644 --- a/tests/baselines/reference/nearbyIdenticalGenericLambdasAssignable.types +++ b/tests/baselines/reference/nearbyIdenticalGenericLambdasAssignable.types @@ -41,7 +41,7 @@ type TC = typeof fC; >fC : () => { v: T; } type TL = () => { v: T }; ->TL : TL +>TL : () => { v: T; } >v : T declare function accA(x: TA): void; diff --git a/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.types b/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.types index 8b5f5df29012d..26630884d1883 100644 --- a/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.types +++ b/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.types @@ -1,6 +1,6 @@ === tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts === type Style = StyleBase | StyleArray; ->Style : Style +>Style : StyleBase | StyleArray interface StyleArray extends Array